Skip to content

Instantly share code, notes, and snippets.

@renatocron
Created July 27, 2015 19:17
Show Gist options
  • Save renatocron/8c956f8545a2c4095e0c to your computer and use it in GitHub Desktop.
Save renatocron/8c956f8545a2c4095e0c to your computer and use it in GitHub Desktop.
use DateTime::Format::Pg;
subtype DataStr, as Str, where {
eval { DateTime::Format::Pg->parse_datetime($_)->datetime };
return $@ eq '';
}, message { "invalid date [$_]" };
coerce DataStr, from Str, via {
DateTime::Format::Pg->parse_datetime($_)->datetime;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment