Main > Programming > Libraries >

DateTime::Format::Builder::Tutorial 0.7807

DateTime::Format::Builder::Tutorial 0.7807

Sponsored Links

DateTime::Format::Builder::Tutorial 0.7807 Ranking & Summary

RankingClick at the star to rank
Ranking Level
User Review: 0 (0 times)
File size: 0.047 MB
Platform: Any Platform
License: Perl Artistic License
Price:
Downloads: 1103
Date added: 2006-10-16
Publisher: Iain Truskett

DateTime::Format::Builder::Tutorial 0.7807 description

DateTime::Format::Builder::Tutorial is a quick class on using Builder.

CREATING A CLASS

As most people who are writing modules know, you start a package with a package declaration and some indication of module version:

package DateTime::Format::ICal;
our $VERSION = 0.04;

After that, you call Builder with some options. There are only a few (detailed later). Right now, were only interested in parsers.

use DateTime::Format::Builder
(
parsers => {
...
}
);

The parsers option takes a reference to a hash of method names and specifications:

parsers => {
parse_datetime => ... ,
parse_datetime_with_timezone => ... ,
...
}

Builder will create methods in your class, each method being a parser that follows the given specifications. It is strongly recommended that one method is called parse_datetime, be it a Builder created method or one of your own.

In addition to creating any of the parser methods it also creates a new() method that can instantiate (or clone) objects of this class. This behaviour can be modified with the constructor option, but we dont need to know that yet.

Each value corresponding to a method name in the parsers list is either a single specification, or a list of specifications. Well start with the simple case.

parse_briefdate => {
params => [ qw( year month day ) ],
regex => qr/^(dddd)(dd)(dd)$/,
},

This will result in a method named parse_briefdate which will take strings in the form 20040716 and return DateTime objects representing that date. A user of the class might write:

use DateTime::Format::ICal;
my $date = "19790716";
my $dt = DateTime::Format::ICal->parse_briefdate( $date );
print "My birth month is ", $dt->month_name, "n";

The regex is applied to the input string, and if it matches, then $1, $2, ... are mapped to the params given and handed to DateTime->new(). Essentially:

my $rv = DateTime->new( year => $1, month => $2, day => $3 );

There are more complicated things one can do within a single specification, but well cover those later.

Often, youll want a method to be able to take one string, and run it against multiple parser specifications. It would be very irritating if the user had to work out what format the datetime string was in and then which method was most appropriate.

So, Builder lets you specify multiple specifications:

parse_datetime => [
{
params => [ qw( year month day hour minute second ) ],
regex => qr/^(dddd)(dd)(dd)T(dd)(dd)(dd)$/,
},
{
params => [ qw( year month day hour minute ) ],
regex => qr/^(dddd)(dd)(dd)T(dd)(dd)$/,
},
{
params => [ qw( year month day hour ) ],
regex => qr/^(dddd)(dd)(dd)T(dd)$/,
},
{
params => [ qw( year month day ) ],
regex => qr/^(dddd)(dd)(dd)$/,
},
],

Its an arrayref of specifications. A parser will be created that will try each of these specifications sequentially, in the order you specified.

DateTime::Format::Builder::Tutorial 0.7807 Screenshot

Advertisements

DateTime::Format::Builder::Tutorial 0.7807 Keywords

Bookmark DateTime::Format::Builder::Tutorial 0.7807

Hyperlink code:
Link for forum:

DateTime::Format::Builder::Tutorial 0.7807 Copyright

WareSeeker periodically updates pricing and software information of DateTime::Format::Builder::Tutorial 0.7807 full version from the publisher, so some information may be slightly out-of-date. You should confirm all information before relying on it. Software piracy is theft, Using crack, password, serial numbers, registration codes, key generators is illegal and prevent future development of DateTime::Format::Builder::Tutorial 0.7807 Edition. Download links are directly from our publisher sites, torrent files or links from rapidshare.com, yousendit.com or megaupload.com are not allowed

Allok Video Splitter 2.2.0 Review:

Name (Required)
Email(Required)
Captcha
Featured Software

Want to place your software product here?
Please contact us for consideration.

Contact WareSeeker.com
Related Software
DateTime::Format::Builder is a Perl module to create datetime parser classes and objects. Free Download
DateTime::Format::Roman is a Perl module with roman day numbering for DateTime objects. Free Download
DateTime::Format::Epoch is a Perl module that can convert DateTimes to/from epoch seconds. Free Download
DateTime::Format::Epoch::Lilian is a Perl module to convert DateTimes to/from Lilian Days. Free Download
DateTime::Format::Epoch::RJD is a Perl module that can convert DateTimes to/from Reduced Julian Days. Free Download
DateTime::Format::Epoch::RataDie is a Perl module that can convert DateTimes to/from Rata Die. Free Download
DateTime::Format::Strptime is a Perl module to parse and format strp and strf time patterns. Free Download
DateTime::Format::Excel is a Perl module that can convert between DateTime and Excel dates. Free Download