| 1 | package SPVM::Time::Local; | ||
| 2 | |||
| 3 | 1 | our $VERSION = '0.118'; | |
| 4 | |||
| 5 | 1 | 1; | |
| 6 | |||
| 7 | =head1 Name | ||
| 8 | |||
| 9 | SPVM::Time::Local - Reverse Operations of localtime and gmtime. | ||
| 10 | |||
| 11 | =head1 Description | ||
| 12 | |||
| 13 | Time::Local class in L<SPVM> performs reverse operations of L<localtime|SPVM::Sys/"localtime"> and L<gmtime|SPVM::Sys/"gmtime"> functions. | ||
| 14 | |||
| 15 | =head1 Usage | ||
| 16 | |||
| 17 | use Sys; | ||
| 18 | use Time::Local; | ||
| 19 | |||
| 20 | # timegm | ||
| 21 | { | ||
| 22 | my $epoch = Sys::Time->time; | ||
| 23 | |||
| 24 | my $tm = Sys->gmtime($epoch); | ||
| 25 | |||
| 26 | my $epoch_again = Time::Local->timegm($tm); | ||
| 27 | } | ||
| 28 | |||
| 29 | # timelocal | ||
| 30 | { | ||
| 31 | my $epoch = Sys::Time->time; | ||
| 32 | |||
| 33 | my $tm_local = Sys->localtime($epoch); | ||
| 34 | |||
| 35 | my $epoch_again = Time::Local->timelocal($tm_local); | ||
| 36 | } | ||
| 37 | |||
| 38 | =head1 Class Methods | ||
| 39 | |||
| 40 | =head2 timelocal | ||
| 41 | |||
| 42 | C<static method timelocal : long ($tm : L<Sys::Time::Tm|SPVM::Sys::Time::Tm>);> | ||
| 43 | |||
| 44 | Converts a L<Sys::Time::Tm|SPVM::Sys::Time::Tm> object to the epoch time. | ||
| 45 | |||
| 46 | This method does the reverse operation of the L<localtime|SPVM::Sys/"localtime"> method in the Sys class. | ||
| 47 | |||
| 48 | Exceptions: | ||
| 49 | |||
| 50 | $tm must be defined. Otherwise an exception is thrown. | ||
| 51 | |||
| 52 | =head2 timegm | ||
| 53 | |||
| 54 | C<static method timegm : long ($tm : L<Sys::Time::Tm|SPVM::Sys::Time::Tm>);> | ||
| 55 | |||
| 56 | Converts a L<Sys::Time::Tm|SPVM::Sys::Time::Tm> object that is C<UTC> to the epoch time. | ||
| 57 | |||
| 58 | This method does the reverse operation of the L<gmtime|SPVM::Sys/"gmtime"> method in the Sys class. | ||
| 59 | |||
| 60 | Exceptions: | ||
| 61 | |||
| 62 | $tm must be defined. Otherwise an exception is thrown. | ||
| 63 | |||
| 64 | =head1 Repository | ||
| 65 | |||
| 66 | L<SPVM::Time::Local - Github|https://github.com/yuki-kimoto/SPVM-Time-Local> | ||
| 67 | |||
| 68 | =head1 Author | ||
| 69 | |||
| 70 | Yuki Kimoto C<kimoto.yuki@gmail.com> | ||
| 71 | |||
| 72 | =head1 Copyright & License | ||
| 73 | |||
| 74 | Copyright (c) 2023 Yuki Kimoto | ||
| 75 | |||
| 76 | MIT License | ||
| 77 |