The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

Name

SPVM::Time::Local - Reverse Manipulation of localtime and gmtime Functions.

Description

The Time::Local class of SPVM has methods for reverse manipulations of localtime and gmtime functions.

Usage

  use Sys::Time
  use Time::Local;
  
  my $epoch = Sys::Time->time;
  my $time_info_local = Sys::Time->localtime($epoch);
  my $time_info_utc = Sys::Time->gmtime($epoch);
  
  my $epoch = Time::Local->timelocal($time_info_local);
  
  my $epoch = Time::Local->timegm($time_info_utc);

Class Methods

timelocal

  static method timelocal : long ($time_info : Sys::Time::Tm);

Converts a Sys::Time::Tm object that is local time to the epoch time.

This method is the reverse manipulation of localtime.

This method is the same as timelocal function of Linux.

  my $epoch = Time::Local->timelocal($time_info_local);

timegm

  static method timegm : long ($time_info : Sys::Time::Tm);

Converts a Sys::Time::Tm object that is UTC to the epoch time.

This method is the reverse manipulation of gmtime.

This method is the same as timegm function of Linux.

  my $epoch = Time::Local->timegm($time_info_utc);

Repository

SPVM::Time::Local - Github

Author

Yuki Kimoto kimoto.yuki@gmail.com

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License