| 1 | package Hessian::Serializer::Date; | ||||||||||
| 2 | |||||||||||
| 3 | 33 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 33 | requires qw/write_integer write_long/; | |||||||||
| 6 | |||||||||||
| 7 | 33 | ▶ | use DateTime; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | #use DateTime::Format::Strptime; | ||||||||||
| 9 | 33 | ▶ | use DateTime::Format::Epoch; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 2 | ▶ | sub write_date { #{{{ | ||||||||
|
Subroutine
write_date: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 12 | 2 | my ($self, $datetime) = @_; | |||||||||
| 13 | 2 | my $formatter = DateTime::Format::Epoch->new( | |||||||||
| 14 | unit => 'milliseconds', | ||||||||||
| 15 | type => 'bigint', | ||||||||||
| 16 | epoch => DateTime->new( | ||||||||||
| 17 | year => 1970, | ||||||||||
| 18 | month => 1, | ||||||||||
| 19 | day => 1, | ||||||||||
| 20 | time_zone => 'UTC' | ||||||||||
| 21 | ) | ||||||||||
| 22 | ); | ||||||||||
| 23 | 2 | my $epoch_time = $formatter->format_datetime($datetime); | |||||||||
| 24 | 2 | my $time = $self->write_long($epoch_time); | |||||||||
| 25 | 2 | ▶ | if ($self->version() == 1) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 1 | $time =~ s/L/d/; | |||||||||
| 27 | } | ||||||||||
| 28 | else { | ||||||||||
| 29 | 1 | $time =~ s/^L/\x4a/; | |||||||||
| 30 | 1 | $time =~ s/^I/\x4b/; | |||||||||
| 31 | |||||||||||
| 32 | } | ||||||||||
| 33 | 2 | return $time; | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | |||||||||||
| 37 | 33 | "one, but we're not the same"; | |||||||||
| 38 | |||||||||||
| 39 | __END__ | ||||||||||