type 'MyApp::DateOnly' => as 'DateTime' => where { blessed($_) && $_->isa('DateTime') && $_->hour == 0 && $_->min == 0 && $_->sec == 0 }; #### coerce 'Search::DateOnly' => from 'DateTime' => via { $_->truncate(to => 'day') }; coerce 'Search::DateOnly' => from 'Str' => via { state $parser = DateTime::Format::Strptime->new( pattern => '%Y/%m/%d'); $parser->parse_datetime($_); }; #### has foo => ( is => 'ro', isa => 'Maybe[MyApp::DateOnly]', coerce => 1, );