NAME

Devel::Ladybug::DateTime - Overloaded Time object class

SYNOPSIS

use Devel::Ladybug::DateTime;

From Epoch:

my $time = Devel::Ladybug::DateTime->new( time() );

From YYYY MM DD hh mm ss:

my $time = Devel::Ladybug::DateTime->newFrom(1999,12,31,23,59,59);

DESCRIPTION

Time object.

Extends Devel::Ladybug::Float. Overloaded for numeric comparisons, stringifies as unix epoch seconds unless overridden.

PUBLIC CLASS METHODS

  • assert(Devel::Ladybug::Class $class: *@rules)

    Returns a new Devel::Ladybug::Type::DateTime instance which encapsulates the received Devel::Ladybug::Subtype rules.

    With exception to ctime and mtime, which default to DATETIME, DOUBLE(15,4) is the default column type for Devel::Ladybug::DateTime. This is done in order to preserve sub-second time resolution. This may be overridden as needed on a per-attribute bases.

    To use DATETIME as the column type, specify it as the value to the columnType subtype arg. When using a DATETIME column, Devel::Ladybug will automatically ask the database to handle any necessary conversion.

    create "YourApp::Example" => {
      someTimestamp  => Devel::Ladybug::DateTime->assert(
        subtype(
          columnType => "DATETIME",
        )
      ),
    
      # ...
    };
  • new(Devel::Ladybug::Class $class: Num $epoch)

    Returns a new Devel::Ladybug::DateTime instance which encapsulates the received value.

    my $object = Devel::Ladybug::DateTime->new($epoch);

SEE ALSO

This file is part of Devel::Ladybug.