DateTime-Lite

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN


        An explicit "time_zone" argument always takes priority over the
        locale extension.

    No die() in normal operation
        Following the Module::Generic / Locale::Unicode error-handling
        philosophy, "DateTime::Lite" never calls "die()" in normal error
        paths.

        Instead it sets a DateTime::Lite::Exception object and returns
        "undef" in scalar context, or an empty list in list context.

        However, if you really want this module to "die" upon error, you can
        pass the "fatal" option with a true value upon object instantiation.

KNOWN DIFFERENCES FROM DateTime
    Validation
        "DateTime" uses Specio / Params::ValidationCompiler for constructor
        validation. "DateTime::Lite" performs equivalent checks manually.
        Error messages are similar but not identical.

    No warnings::register abuse
        "DateTime::Lite" uses "warnings::enabled" consistently and does not
        depend on the "warnings::register" mechanism for user-facing output.

METHODS NOT IMPLEMENTED
    None at this time. If you encounter a method missing from the DateTime
    API, please file a report.

CONSTRUCTORS
  new
    Accepted parameters are:

    *   "year" (required)

    *   "month"

    *   "day"

    *   "hour"

    *   "minute"

    *   "second"

    *   "nanosecond"

    *   "time_zone"

        The time zone for the datetime. Accepts:

        *       A zone name string, such as "Asia/Tokyo", a fixed-offset
                string such as "+09:00", "UTC", "floating", or "local".

        *       A DateTime::Lite::TimeZone object.

        *       A hash reference whose keys are passed directly to "new" in
                DateTime::Lite::TimeZone. This allows passing options that
                are not available on the string form, such as "extended =>
                1" (to resolve timezone abbreviations such as "JST" or
                "CET"), or "latitude"/"longitude" for coordinate-based
                resolution:

                    time_zone => { name => 'JST', extended => 1 }
                    time_zone => { latitude => 35.658558, longitude => 139.745504 }

        If omitted, and the "locale" argument carries a BCP47 "-u-tz-"
        extension, such as "he-IL-u-ca-hebrew-tz-jeruslm", the corresponding
        IANA canonical timezone is resolved automatically. If neither is
        provided, the default floating timezone is used (or
        $ENV{PERL_DATETIME_DEFAULT_TZ} if set).

    *   "locale"

        Any valid locale as defined by the Unicode CLDR (Common Locale Data
        Repository), and BCP47. See Locale::Unicode

    *   "formatter"

    *   "fatal"

    Returns the new object upon success, or sets an error and returns
    "undef" in scalar context, or an empty list in list context. In chaining
    (object context), it returns a dummy object ("DateTime::Lite::Null") to
    avoid the typical "Can't call method '%s' on an undefined value"

  from_day_of_year
        my $dt2 = DateTime::Lite->from_day_of_year(
            year        => 2026,
            day_of_year => 100,
            time_zone   => 'UTC',
            locale      => 'fr-FR',
        );

    Constructs from a year and day-of-year (1-366).

    Returns the new object upon success, or sets an error and returns
    "undef" in scalar context, or an empty list in list context. In chaining
    (object context), it returns a dummy object ("DateTime::Lite::Null") to
    avoid the typical "Can't call method '%s' on an undefined value"

  from_epoch
        my $dt = DateTime::Lite->from_epoch(
            epoch     => 1775769030,
            time_zone => 'Asia/Tokyo',
            locale    => 'ja-JP',
            formatter => $formatter,
        );

    Constructs from a Unix epoch value (integer or float). Non-integer
    values are rounded to the nearest microsecond.

    It accepts the "time_zone", "locale", and "formatter" parameters.

    The returned object will be in the "UTC" time zone.

    If you provide the "time_zone" argument, it will be applied *after* the
    object is instantiated. Thus, the epoch value provided will always be
    set in the UTC time zone.

    For example:



( run in 1.105 second using v1.01-cache-2.11-cpan-1bcd28dbaf1 )