Download Shareware and Freeware Software for Windows, Linux, Macintosh, PDA

line Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

Serving Software Downloads in 976 Categories, Downloaded 38.876.252 Times

DateTime::Format::Builder::Tutorial 0.7807

  Date Added: August 21, 2010  |  Visits: 1.063

DateTime::Format::Builder::Tutorial

Report Broken Link
Printer Friendly Version


Product Homepage
Download (87 downloads)



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..

Requirements: No special requirements
Platforms: Linux
Keyword: Class Datetime Datetimeformatbuildertutorial Dd Ical Libraries Method Month Month Day Parse Programming Year Year Month Day
Users rating: 0/10

License: Freeware Size: 48.13 KB
USER REVIEWS
More Reviews or Write Review


DATETIME::FORMAT::BUILDER::TUTORIAL RELATED
Miscellaneous  -  Class with default method handler 1.0
This script is a class whose objects can handle undefined method calls, passing them on to a default handler.
 
Libraries  -  DateTime::Cron::Simple 0.2
DateTime::Cron::Simple is a Perl module that can parse a cron entry and check against current time. SYNOPSIS use DateTime::Cron::Simple; $c = DateTime::Cron::Simple->new($cron); $boolean = $c->validate_time; $c->new_cron($cron); This...
3.07 KB  
Development Tools  -  xmlParser for XML Tools 1.1
Class w/examples to provide a method to easily extract data from XML files
10 KB  
Miscellaneous  -  Simple Singleton 1.0
This script is an implementation of the singleton without using the __new__ class but by implementing the __call__ method in the metaclass.
 
Sports  -  Duckworth Lewis (DL) Calculator 1.0.0.0
Are you an Avid Cricket Fan ? Always wanted to predict the D/L score before it is announced ? Always wanted to do it but never knew how to ? Not Anymore ! With this app you can compute score using the D/L method for One-Day Internationals (T20...
4 MB  
Libraries  -  DateTime::Calendar::Pataphysical 0.04
DateTime::Calendar::Pataphysical is a Perl module with dates in the pataphysical calendar. SYNOPSIS use DateTime::Calendar::Pataphysical; $dt = DateTime::Calendar::Pataphysical->new( year => 1752, month => 10, day => 4 );...
23.55 KB  
Libraries  -  Class::Declare::Attributes 0.04
Class::Declare::Attributes is a Perl module with Class::Declare method types using Perl attributes. SYNOPSIS package My::Class; use 5.006; use strict; use warnings; use base qw( Class::Declare::Attributes ); # declare the...
21.5 KB  
Libraries  -  Class::Classgen::New 3.03
Class::Classgen::New is a Perl module that creates the new() method for classes generated by classgen. SYNOPSIS Used within classgen. The main purpose of New.pm is to write the new() method for a class generated by classgen. It provides code...
24.58 KB  
Libraries  -  iCal::Parser 1.14
iCal::Parser is a Perl module to parse iCalendar files into a data structure. SYNOPSIS use iCal::Parser my $parser=iCal::Parser->new(); my $hash=$parser->parse($file); $parser->parse($another_file); my $combined=$parser->calendar; my...
28.67 KB  
Libraries  -  DateTime::Precise 1.05
DateTime::Precise can perform common time and date operations with additional GPS operations. SYNOPSIS use DateTime::Precise; use DateTime::Precise qw(:TimeVars); # Constructors and ways to set time. $t1 = DateTime::Precise->new; $t2 =...
34.82 KB  
NEW DOWNLOADS IN PROGRAMMING, LIBRARIES
Programming  -  Cedalion for Linux 0.2.6
Cedalion is a programming language that allows its users to add new abstractions and define (and use) internal DSLs. Its innovation is in the fact that it uses projectional editing to allow the new abstractions to have no syntactic limitations.
471.04 KB  
Programming  -  Math::GMPf 0.29
Math::GMPf - perl interface to the GMP library's floating point (mpf) functions.
30.72 KB  
Programming  -  Net::Wire10 1.08
Net::Wire10 is a Pure Perl connector that talks to Sphinx, MySQL and Drizzle servers. Net::Wire10 implements the low-level network protocol, alias the MySQL wire protocol version 10, necessary for talking to one of the aforementioned...
30.72 KB  
Programming  -  logilab-common 0.56.2
a bunch of modules providing low level functionnalities shared among some python projects devel Please note that some of the modules have some extra dependencies. For instance, logilab.common.db will require a db-api 2.0 compliant...
174.08 KB  
Programming  -  OpenSSL for linux 1.0.0a
The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, full-featured, and Open Source toolkit implementing the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well as a...
3.83 MB  
Libraries  -  wolfSSL 4.0.0
The wolfSSL embedded SSL/TLS library is a lightweight SSL library written in ANSI standard C and targeted for embedded and RTOS environments - primarily because of its small size, speed, and feature set. It is commonly used in standard operating...
3.88 MB  
Libraries  -  EuGTK 4.8.9
Makes it easy to develop good- looking, fast, cross-platform programs that run on Linux, OS X, and Windows. Euphoria is a very fast interpreted/compiled language with straight-forward syntax. EuGTK allows programming in a clean, object-oriented...
10.68 MB  
Libraries  -  Linux User Group Library Manager 1.0
The LUG Library Manager is a project to help Linux User Groups start their own library. A LUG library is helpful to the community at large because it increases access to information, and gives everyone the opportunity to become more knowledgeable.
5.35 KB  
Libraries  -  Module::MakefilePL::Parse 0.12
Module::MakefilePL::Parse is a Perl module to parse required modules from Makefile.PL. SYNOPSIS use Module::MakefilePL::Parse; open $fh, Makefile.PL; $parser = Module::MakefilePL::Parse->new( join("", ) ); $info = $parser->required;...
8.19 KB  
Libraries  -  sqlpp 0.06
sqlpp Perl package is a SQL preprocessor. sqlpp is a conventional cpp-alike preprocessor taught to understand SQL ( PgSQL, in particular) syntax specificities. In addition to the standard #define/#ifdef/#else/#endif cohort, provides also...
10.24 KB