Coder Social home page Coder Social logo

datetimex-factory's Introduction

NAME

DateTimeX::Factory - DateTime factory module with default options.

VERSION

This document describes DateTimeX::Factory version 1.00.

SYNOPSIS

use DateTimeX::Factory;

my $factory = DateTimeX::Factory->new(
    time_zone => 'Asia/Tokyo',
);
my $now = $factory->now;

DESCRIPTION

DateTime factory module with default options. This module include wrapper of default constructors and some useful methods.

METHODS

new(%params)

Create factory instance. all parameters thrown to factory methods

my $factory = DateTimeX::Factory->new(time_zone => 'Asia/Tokyo');

create(%params)

Call DateTime->new with default parameter.

my $datetime = $factory->create(year => 2012, month => 1, day => 24, hour => 23, minute => 16, second => 5);

now(%params), today(%params), from_epoch(%params), last_day_of_month(%params), from_day_of_year(%params)

See document of DateTime. But, these methods create DateTime instance by original method with default parameter.

strptime($string, $pattern)

Parse string by DateTime::Format::Strptime with default parameter.

my $datetime = $factory->strptime('2012-01-24 23:16:05', '%Y-%m-%d %H:%M:%S');

from_mysql_datetime($string)

Parse MySQL DATETIME string with default parameter.

#equals my $datetime = $factory->strptime('2012-01-24 23:16:05', '%Y-%m-%d %H:%M:%S');
my $datetime = $factory->from_mysql_datetime('2012-01-24 23:16:05');

from_mysql_date($string)

Parse MySQL DATE string with default parameter.

#equals my $date = $factory->strptime('2012-01-24', '%Y-%m-%d');
my $date = $factory->from_mysql_date('2012-01-24');

from_ymd($string, $delimiter)

Parse string like DateTime::ymd return value with default parameter.

#equals my $date = $factory->strptime('2012/01/24', '%Y/%m/%d');
my $date = $factory->from_ymd('2012-01-24', '/');

tommorow(%params)

Create next day DateTime instance.

#equals my $tommorow = $factory->today->add(days => 1);
my $tommorow = $factory->tommorow;

yesterday(%params)

Create previous day DateTime instance.

#equals my $yesterday = $factory->today->subtract(days => 1);
my $yesterday = $factory->yesterday;

DEPENDENCIES

Perl 5.10.1 or later. Class::Accessor::Lite DateTime DateTime::Format::Strptime

BUGS

All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT.

SEE ALSO

perl

AUTHOR

Nishibayashi Takuji [email protected]

LICENSE AND COPYRIGHT

Copyright (c) 2012, Nishibayashi Takuji. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

datetimex-factory's People

Contributors

takuji31 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

datetimex-factory's Issues

Failed test 'Correct now instance Asia/Tokyo from instance method'

Some of my smoker machines report failures like this:

#   Failed test 'Correct now instance Asia/Tokyo from instance method'
#   at t/003_constructors.t line 18.
#          got: '2016-09-04T17:35:18'
#     expected: '2016-09-04T17:35:20'
# Looks like you failed 1 test of 21.
t/003_constructors.t ... 
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/21 subtests 

Maybe this happens if the machine is busy?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.