NAME
OP::DateTime - Overloaded Time object class
SYNOPSIS
use OP::DateTime;
From Epoch:
my $time = OP::DateTime->new( time() );
From YYYY MM DD hh mm ss:
my $time = OP::DateTime->newFrom(1999,12,31,23,59,59);
DESCRIPTION
Time object.
Extends OP::Object, Time::Piece. Overloaded for numeric comparisons, stringifies as unix epoch seconds unless overridden.
PUBLIC CLASS METHODS
assert(OP::Class $class: *@rules)
Returns a new OP::Type::DateTime instance which encapsulates the received OP::Subtype rules.
By default, a column type of DOUBLE(15,4) is used, because MySQL's DATETIME type does not support sub-second resolution. This may be overridden as needed.
To use DATETIME as the column type, specify it as the value to the
columnType
subtype arg. When using a DATETIME column, OP will automatically ask MySQL to handle any necessary conversion.create "OP::Example" => { someTimestamp => OP::DateTime->assert( subtype( optional => true, columnType => "DATETIME", ) ), # ... };
new(OP::Class $class: Num $epoch)
Returns a new OP::DateTime instance which encapsulates the received value.
my $object = OP::DateTime->new($epoch);
SEE ALSO
See the Time::Piece module for time formatting and manipulation methods inherited by this class.
This file is part of OP.