DateTime::Functions - Procedural interface to DateTime functions


DateTime-Functions documentation Contained in the DateTime-Functions distribution.

Index


Code Index:

NAME

Top

DateTime::Functions - Procedural interface to DateTime functions

VERSION

Top

This document describes version 0.10 of DateTime::Functions, released December 9, 2010

SYNOPSIS

Top

    use DateTime::Functions;
    print today->year;
    print now->strftime("%Y-%m-%d %H:%M:%S");

DESCRIPTION

Top

This module simply exports all class methods of DateTime into the caller's namespace.

METHODS

Top

Unless otherwise noted, all methods correspond to the same-named class method in DateTime. Please see DateTime for which parameters are supported.

Constructors

All constructors can die when invalid parameters are given. They all return DateTime objects, except for duration() which returns a DateTime::Duration object.

* datetime( ... )

Equivalent to DateTime->new( ... ).

* duration( ... )

Equivalent to DateTime::Duration->new( ... ).

* from_epoch( epoch => $epoch, ... )
* now( ... )
* today( ... )
* from_object( object => $object, ... )
* last_day_of_month( ... )
* from_day_of_year( ... )

Utility Functions

* default_locale( $locale )

Equivalent to DateTime->DefaultLocale( $locale ).

* compare
* compare_ignore_floating

SEE ALSO

Top

DateTime

AUTHORS

Top

唐鳳 <cpan@audreyt.org>

CC0 1.0 Universal

Top

To the extent possible under law, 唐鳳 has waived all copyright and related or neighboring rights to DateTime-Functions.

This work is published from Taiwan.

http://creativecommons.org/publicdomain/zero/1.0


DateTime-Functions documentation Contained in the DateTime-Functions distribution.
package DateTime::Functions;

use 5.006;
use strict;
use base 'Exporter';
use vars qw( @EXPORT $VERSION );

$VERSION = '0.10';

use DateTime ();
use Exporter;

@EXPORT = qw(
    datetime from_epoch now today from_object
    last_day_of_month from_day_of_year default_locale
    compare compare_ignore_floating duration
);

foreach my $func (@EXPORT) {
    no strict 'refs';
    my $method = $func;
    next if $func eq 'duration';
    $method = 'new' if $func eq 'datetime';
    $method = 'DefaultLocale' if $func eq 'default_locale';
    *$func = sub { DateTime->can($method)->('DateTime', @_) };
}

sub duration {
    require DateTime::Duration;
    return DateTime::Duration->new(@_);
}

1;