Subject: | Milliseconds in builder |
Hi,
I have:
has event_datetime => (
is => 'rw',
isa => 'DateTime',
lazy => 1,
default => sub {
DateTime->from_epoch( epoch => time() )->set_time_zone('Europe/London')
->format_cldr(q{yyyy-MM-dd'T'HH:mm:ss.SSSSSS});
}
);
but because I want milliseconds which standard time that DateTime->now uses from_epoch with doesn't, I use Time::HiRes;
This blows up with:
Attribute (event_datetime) does not pass the type constraint because: Validation failed for 'DateTime' with value "2019-09-12T10:24:26.423671" at accessor SureVoIP::API::AuditLog::event_datetime (defined at /home/suretec/surevoip-api/SureVoIP-API/t/../lib/SureVoIP/API/AuditLog.pm line 25) line 11
SureVoIP::API::AuditLog::event_datetime('SureVoIP::API::AuditLog=HASH(0xe7bde38)') called at /home/suretec/surevoip-api/SureVoIP-API/t/../lib/SureVoIP/API/Model/AuditLog.pm line 71
SureVoIP::API::Model::AuditLog::record('SureVoIP::API::Model::AuditLog', 'SureVoIP::API=HASH(0xe620fa0)', 'SureVoIP::API::Event=HASH(0x11f8f58)') called at t/45-auditlogs.t line 35
# Looks like your test exited with 255 just after 4
I've had to switch isa to a Str, but I lose a lot.
Thanks.