NAME

Crop::DateTime - General purpose Date and Time class for Crop framework

SYNOPSIS

use Crop::DateTime;
my $dt = Crop::DateTime->new();
my $epoch_ms = $dt->epoch_milli;
my $timestamp = $dt->timestamp;

DESCRIPTION

Crop::DateTime provides date and time handling for the Crop framework, including high-resolution time, time zone support, and formatting utilities. By default, the time zone is set to Moscow time (UTC+3).

CONSTANTS

  • DEFAULT_TIMEZONE The default time zone (03:00, Moscow time).

ATTRIBUTES

  • sec Seconds since the epoch (read-only).

  • usec Microseconds (read-only).

  • tz Time zone (defaults to 03:00).

METHODS

new([$time])

my $dt = Crop::DateTime->new();
my $dt = Crop::DateTime->new('2025-05-23 12:34:56.123456+03');

Creates a new Crop::DateTime object. If $time is provided (in Postgres format), it is used; otherwise, the current time is used.

epoch_milli

my $ms = $dt->epoch_milli;

Returns the epoch time in milliseconds as a string.

timestamp

my $ts = $dt->timestamp;

Returns the time in the format 'TIMESTAMP(6) WITH TIME ZONE'.

DEPENDENCIES

  • Time::HiRes =item * Date::Parse

AUTHORS

Euvgenio (Core Developer)

Alex (Contributor)

COPYRIGHT AND LICENSE

Apache 2.0