strftime
Sponsored Links
Sponsored Links
Secleted [ 0 ] software to compare
Results 1 - 15 of about 18
Data::Faker::DateTime 0.07
Data::Faker::DateTime is a Data::Faker plugin. more>>
Data::Faker::DateTime is a Data::Faker plugin.
DATA PROVIDERS
unixtime
Return a unix time (seconds since the epoch) for a random time between the epoch and now.
date
Return a random date as a string, using a random date format (see date_format).
time
Return a random time as a string, using a random time format (see time_format).
rfc822
Return an RFC 822 formatted random date. This method may not work on systems using a non-GNU strftime implementation (kindly let me know if that is the case.)
ampm
Returns am or pm randomly (in the current locale) using one of the formats specified in ampm_format.
time_format
Return a random time format.
date_format
Return a random date format.
ampm_format
Return a random am/pm format.
datetime_format
Return a random date and time format.
month
Return a random month name, unabbreviated, in the current locale.
month_abbr
Return a random month name, abbreviated, in the current locale.
weekday
Return a random weekday name, unabbreviated, in the current locale.
weekday_abbr
Return a random weekday name, abbreviated, in the current locale.
sqldate
Return a random date in the ISO8601 format commonly used by SQL servers (YYYY-MM-DD).
datetime_locale
Return a datetime string in the preferred date representation for the current locale, for a random date.
date_locale
Return a date string in the preferred date representation for the current locale, for a random date.
time_locale
Return a time string in the preferred date representation for the current locale, for a random date.
century
Return a random century number.
dayofmonth
Return a random day of the month.
<<lessDATA PROVIDERS
unixtime
Return a unix time (seconds since the epoch) for a random time between the epoch and now.
date
Return a random date as a string, using a random date format (see date_format).
time
Return a random time as a string, using a random time format (see time_format).
rfc822
Return an RFC 822 formatted random date. This method may not work on systems using a non-GNU strftime implementation (kindly let me know if that is the case.)
ampm
Returns am or pm randomly (in the current locale) using one of the formats specified in ampm_format.
time_format
Return a random time format.
date_format
Return a random date format.
ampm_format
Return a random am/pm format.
datetime_format
Return a random date and time format.
month
Return a random month name, unabbreviated, in the current locale.
month_abbr
Return a random month name, abbreviated, in the current locale.
weekday
Return a random weekday name, unabbreviated, in the current locale.
weekday_abbr
Return a random weekday name, abbreviated, in the current locale.
sqldate
Return a random date in the ISO8601 format commonly used by SQL servers (YYYY-MM-DD).
datetime_locale
Return a datetime string in the preferred date representation for the current locale, for a random date.
date_locale
Return a date string in the preferred date representation for the current locale, for a random date.
time_locale
Return a time string in the preferred date representation for the current locale, for a random date.
century
Return a random century number.
dayofmonth
Return a random day of the month.
Download (0.020MB)
Added: 2006-10-25 License: Perl Artistic License Price:
1096 downloads
Time::Piece 1.11
Time::Piece is a Perl module that contains Object Oriented time objects. more>>
Time::Piece is a Perl module that contains Object Oriented time objects.
SYNOPSIS
use Time::Piece;
my $t = localtime;
print "Time is $tn";
print "Year is ", $t->year, "n";
This module replaces the standard localtime and gmtime functions with implementations that return objects. It does so in a backwards compatible manner, so that using localtime/gmtime in the way documented in perlfunc will still return what you expect.
The module actually implements most of an interface described by Larry Wall on the perl5-porters mailing list here: http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2000-01/msg00241.html
USAGE
After importing this module, when you use localtime or gmtime in a scalar context, rather than getting an ordinary scalar string representing the date and time, you get a Time::Piece object, whose stringification happens to produce the same effect as the localtime and gmtime functions. There is also a new() constructor provided, which is the same as localtime(), except when passed a Time::Piece object, in which case its a copy constructor. The following methods are available on the object:
$t->sec # also available as $t->second
$t->min # also available as $t->minute
$t->hour # 24 hour
$t->mday # also available as $t->day_of_month
$t->mon # 1 = January
$t->_mon # 0 = January
$t->monname # Feb
$t->month # same as $t->monname
$t->fullmonth # February
$t->year # based at 0 (year 0 AD is, of course 1 BC)
$t->_year # year minus 1900
$t->yy # 2 digit year
$t->wday # 1 = Sunday
$t->_wday # 0 = Sunday
$t->day_of_week # 0 = Sunday
$t->wdayname # Tue
$t->day # same as wdayname
$t->fullday # Tuesday
$t->yday # also available as $t->day_of_year, 0 = Jan 01
$t->isdst # also available as $t->daylight_savings
$t->hms # 12:34:56
$t->hms(".") # 12.34.56
$t->time # same as $t->hms
$t->ymd # 2000-02-29
$t->date # same as $t->ymd
$t->mdy # 02-29-2000
$t->mdy("/") # 02/29/2000
$t->dmy # 29-02-2000
$t->dmy(".") # 29.02.2000
$t->datetime # 2000-02-29T12:34:56 (ISO 8601)
$t->cdate # Tue Feb 29 12:34:56 2000
"$t" # same as $t->cdate
$t->epoch # seconds since the epoch
$t->tzoffset # timezone offset in a Time::Seconds object
$t->julian_day # number of days since Julian period began
$t->mjd # modified Julian date (JD-2400000.5 days)
$t->week # week number (ISO 8601)
$t->is_leap_year # true if it its
$t->month_last_day # 28-31
$t->time_separator($s) # set the default separator (default ":")
$t->date_separator($s) # set the default separator (default "-")
$t->day_list(@days) # set the default weekdays
$t->mon_list(@days) # set the default months
$t->strftime(FORMAT) # same as POSIX::strftime (without the overhead
# of the full POSIX extension)
$t->strftime() # "Tue, 29 Feb 2000 12:34:56 GMT"
Time::Piece->strptime(STRING, FORMAT)
# see strptime man page. Creates a new
# Time::Piece object
<<lessSYNOPSIS
use Time::Piece;
my $t = localtime;
print "Time is $tn";
print "Year is ", $t->year, "n";
This module replaces the standard localtime and gmtime functions with implementations that return objects. It does so in a backwards compatible manner, so that using localtime/gmtime in the way documented in perlfunc will still return what you expect.
The module actually implements most of an interface described by Larry Wall on the perl5-porters mailing list here: http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2000-01/msg00241.html
USAGE
After importing this module, when you use localtime or gmtime in a scalar context, rather than getting an ordinary scalar string representing the date and time, you get a Time::Piece object, whose stringification happens to produce the same effect as the localtime and gmtime functions. There is also a new() constructor provided, which is the same as localtime(), except when passed a Time::Piece object, in which case its a copy constructor. The following methods are available on the object:
$t->sec # also available as $t->second
$t->min # also available as $t->minute
$t->hour # 24 hour
$t->mday # also available as $t->day_of_month
$t->mon # 1 = January
$t->_mon # 0 = January
$t->monname # Feb
$t->month # same as $t->monname
$t->fullmonth # February
$t->year # based at 0 (year 0 AD is, of course 1 BC)
$t->_year # year minus 1900
$t->yy # 2 digit year
$t->wday # 1 = Sunday
$t->_wday # 0 = Sunday
$t->day_of_week # 0 = Sunday
$t->wdayname # Tue
$t->day # same as wdayname
$t->fullday # Tuesday
$t->yday # also available as $t->day_of_year, 0 = Jan 01
$t->isdst # also available as $t->daylight_savings
$t->hms # 12:34:56
$t->hms(".") # 12.34.56
$t->time # same as $t->hms
$t->ymd # 2000-02-29
$t->date # same as $t->ymd
$t->mdy # 02-29-2000
$t->mdy("/") # 02/29/2000
$t->dmy # 29-02-2000
$t->dmy(".") # 29.02.2000
$t->datetime # 2000-02-29T12:34:56 (ISO 8601)
$t->cdate # Tue Feb 29 12:34:56 2000
"$t" # same as $t->cdate
$t->epoch # seconds since the epoch
$t->tzoffset # timezone offset in a Time::Seconds object
$t->julian_day # number of days since Julian period began
$t->mjd # modified Julian date (JD-2400000.5 days)
$t->week # week number (ISO 8601)
$t->is_leap_year # true if it its
$t->month_last_day # 28-31
$t->time_separator($s) # set the default separator (default ":")
$t->date_separator($s) # set the default separator (default "-")
$t->day_list(@days) # set the default weekdays
$t->mon_list(@days) # set the default months
$t->strftime(FORMAT) # same as POSIX::strftime (without the overhead
# of the full POSIX extension)
$t->strftime() # "Tue, 29 Feb 2000 12:34:56 GMT"
Time::Piece->strptime(STRING, FORMAT)
# see strptime man page. Creates a new
# Time::Piece object
Download (0.020MB)
Added: 2007-08-21 License: Perl Artistic License Price:
795 downloads
DateTime::Precise 1.05
DateTime::Precise can perform common time and date operations with additional GPS operations. more>>
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 = DateTime::Precise->new(1998. 4. 3 12:13:44.054);
$t3 = DateTime::Precise->new(time() - 100.23456);
$t4 = DateTime::Precise->new(1998.04.24);
$t1->set_localtime_from_epoch_time;
$t1->set_gmtime_from_epoch_time(time + 120.987);
$t1->set_from_datetime(1998.03.23 16:58:14.65);
$t1->set_time(YDHMS, 1998, 177, 9, 15, 26.5);
# This is the same as $d3->set_from_datetime(...)
$t3->dscanf("%^Y.%M.%D %h:%m:%s", "1998.03.25 20:25:23");
if ($msg = $d1->dscanf("%~M", $input)) {
print "error: $msgn";
print "Must enter a three-letter month abbrev.n";
}
# Get different parts of the time.
$year = $t3->year;
$month = $t3->month;
$day = $t3->day;
$hours = $t3->hours;
$minutes = $t3->minutes;
$seconds = $t3->seconds;
($year, $day_of_year) = $t3->get_time(Yj);
# Print times and dates.
print $t2->asctime;
print $t2->strftime(%T %C%n);
print $t2->dprintf("%^Y.%M.%D %h:%m:%s"); # datetime
print $t2->dprintf("%~w %~M %-D %h:%m:%s CST %^Y"); # ctime
# Copy times.
my $t4 = $t2->copy;
# Set one time object to the same time as another: set $t3 equal to $t2.
$t3->clone($t2);
# Find the difference between two times.
$secs_from_midnight = $t4 - $t1;
$secs_from_midnight = $t4->diff($t1);
# Add seconds, days, months, etc to time.
$t1 = $t4 + 3600; # $t1 is now an hour after midnight
$t1->inc_month(2); # add two months to $t1
$t1->floor_month; # set $t1 to the first of the month
$t1 -= 0.25; # subtract 1/4 of a second from $t1
# Can compare and sort DateTime::Precise.
print "Its late!!!" if ($t1 > $t4);
@sorted = sort @birthdays; # normal comparisons work fine
# Get the GPS weeks, seconds and day.
$gps_week = $t1->gps_week;
$gps_seconds = $t1->gps_seconds;
$gps_day = $t1->gps_day;
($gps_week, $gps_seconds, $gps_day) = $t1->gps_week_seconds_day;
<<lessSYNOPSIS
use DateTime::Precise;
use DateTime::Precise qw(:TimeVars);
# Constructors and ways to set time.
$t1 = DateTime::Precise->new;
$t2 = DateTime::Precise->new(1998. 4. 3 12:13:44.054);
$t3 = DateTime::Precise->new(time() - 100.23456);
$t4 = DateTime::Precise->new(1998.04.24);
$t1->set_localtime_from_epoch_time;
$t1->set_gmtime_from_epoch_time(time + 120.987);
$t1->set_from_datetime(1998.03.23 16:58:14.65);
$t1->set_time(YDHMS, 1998, 177, 9, 15, 26.5);
# This is the same as $d3->set_from_datetime(...)
$t3->dscanf("%^Y.%M.%D %h:%m:%s", "1998.03.25 20:25:23");
if ($msg = $d1->dscanf("%~M", $input)) {
print "error: $msgn";
print "Must enter a three-letter month abbrev.n";
}
# Get different parts of the time.
$year = $t3->year;
$month = $t3->month;
$day = $t3->day;
$hours = $t3->hours;
$minutes = $t3->minutes;
$seconds = $t3->seconds;
($year, $day_of_year) = $t3->get_time(Yj);
# Print times and dates.
print $t2->asctime;
print $t2->strftime(%T %C%n);
print $t2->dprintf("%^Y.%M.%D %h:%m:%s"); # datetime
print $t2->dprintf("%~w %~M %-D %h:%m:%s CST %^Y"); # ctime
# Copy times.
my $t4 = $t2->copy;
# Set one time object to the same time as another: set $t3 equal to $t2.
$t3->clone($t2);
# Find the difference between two times.
$secs_from_midnight = $t4 - $t1;
$secs_from_midnight = $t4->diff($t1);
# Add seconds, days, months, etc to time.
$t1 = $t4 + 3600; # $t1 is now an hour after midnight
$t1->inc_month(2); # add two months to $t1
$t1->floor_month; # set $t1 to the first of the month
$t1 -= 0.25; # subtract 1/4 of a second from $t1
# Can compare and sort DateTime::Precise.
print "Its late!!!" if ($t1 > $t4);
@sorted = sort @birthdays; # normal comparisons work fine
# Get the GPS weeks, seconds and day.
$gps_week = $t1->gps_week;
$gps_seconds = $t1->gps_seconds;
$gps_day = $t1->gps_day;
($gps_week, $gps_seconds, $gps_day) = $t1->gps_week_seconds_day;
Download (0.034MB)
Added: 2007-08-09 License: Perl Artistic License Price:
807 downloads
Time::Format 1.02
Time::Format is a Perl module for easy-to-use date/time formatting. more>>
Time::Format is a Perl module for easy-to-use date/time formatting.
SYNOPSIS
use Time::Format qw(%time %strftime %manip);
$time{$format}
$time{$format, $unixtime}
print "Today is $time{yyyy/mm/dd}n";
print "Yesterday was $time{yyyy/mm/dd, time-24*60*60}n";
print "The time is $time{hh:mm:ss}n";
print "Another time is $time{H:mm am tz, $another_time}n";
print "Timestamp: $time{yyyymmdd.hhmmss.mmm}n";
%time also accepts Date::Manip strings and DateTime objects:
$dm = Date::Manip::ParseDate(last monday);
print "Last monday was $time{Month d, yyyy, $dm}";
$dt = DateTime->new (....);
print "Heres another date: $time{m/d/yy, $dt}";
It also accepts most ISO-8601 date/time strings:
$t = 2005/10/31T17:11:09; # date separator: / or - or .
$t = 2005-10-31 17.11.09; # in-between separator: T or _ or space
$t = 20051031_171109; # time separator: : or .
$t = 20051031171109; # separators may be omitted
$t = 2005/10/31; # date-only is okay
$t = 17:11:09; # time-only is okay
# But not:
$t = 20051031; # date-only without separators
$t = 171109; # time-only without separators
# ...because those look like epoch time numbers.
%strftime works like POSIXs strftime, if you like those %-formats.
$strftime{$format}
$strftime{$format, $unixtime}
$strftime{$format, $sec,$min,$hour, $mday,$mon,$year, $wday,$yday,$isdst}
print "POSIXish: $strftime{%A, %B %d, %Y, 0,0,0,12,11,95,2}n";
print "POSIXish: $strftime{%A, %B %d, %Y, 1054866251}n";
print "POSIXish: $strftime{%A, %B %d, %Y}n"; # current time
%manip works like Date::Manips UnixDate function.
$manip{$format};
$manip{$format, $when};
print "Date::Manip: $manip{%m/%d/%Y}n"; # current time
print "Date::Manip: $manip{%m/%d/%Y,last Tuesday}n";
These can also be used as standalone functions:
use Time::Format qw(time_format time_strftime time_manip);
print "Today is ", time_format(yyyy/mm/dd, $some_time), "n";
print "POSIXish: ", time_strftime(%A %B %d, %Y,$some_time), "n";
print "Date::Manip: ", time_manip(%m/%d/%Y,$some_time), "n";
This module creates global pseudovariables which format dates and times, according to formatting codes you pass to them in strings.
The %time formatting codes are designed to be easy to remember and use, and to take up just as many characters as the output time value whenever possible. For example, the four-digit year code is "yyyy", the three-letter month abbreviation is "Mon".
The nice thing about having a variable-like interface instead of function calls is that the values can be used inside of strings (as well as outside of strings in ordinary expressions). Dates are frequently used within strings (log messages, output, data records, etc.), so having the ability to interpolate them directly is handy.
Perl allows arbitrary expressions within curly braces of a hash, even when that hash is being interpolated into a string. This allows you to do computations on the fly while formatting times and inserting them into strings. See the "yesterday" example above.
The format strings are designed with programmers in mind. What do you need most frequently? 4-digit year, month, day, 24-based hour, minute, second -- usually with leading zeroes. These six are the easiest formats to use and remember in Time::Format: yyyy, mm, dd, hh, mm, ss. Variants on these formats follow a simple and consistent formula. This module is for everyone who is weary of trying to remember strftime(3)s arcane codes, or of endlessly writing $t[4]++; $t[5]+=1900 as you manually format times or dates.
Note that mm (and related codes) are used both for months and minutes. This is a feature. %time resolves the ambiguity by examining other nearby formatting codes. If its in the context of a year or a day, "month" is assumed. If in the context of an hour or a second, "minute" is assumed.
The format strings are not meant to encompass every date/time need ever conceived. But how often do you need the day of the year (strftimes %j) or the week number (strftimes %W)?
For capabilities that %time does not provide, %strftime provides an interface to POSIXs strftime, and %manip provides an interface to the Date::Manip modules UnixDate function.
If the companion module Time::Format_XS is also installed, Time::Format will detect and use it. This will result in a significant speed increase for %time and time_format.
<<lessSYNOPSIS
use Time::Format qw(%time %strftime %manip);
$time{$format}
$time{$format, $unixtime}
print "Today is $time{yyyy/mm/dd}n";
print "Yesterday was $time{yyyy/mm/dd, time-24*60*60}n";
print "The time is $time{hh:mm:ss}n";
print "Another time is $time{H:mm am tz, $another_time}n";
print "Timestamp: $time{yyyymmdd.hhmmss.mmm}n";
%time also accepts Date::Manip strings and DateTime objects:
$dm = Date::Manip::ParseDate(last monday);
print "Last monday was $time{Month d, yyyy, $dm}";
$dt = DateTime->new (....);
print "Heres another date: $time{m/d/yy, $dt}";
It also accepts most ISO-8601 date/time strings:
$t = 2005/10/31T17:11:09; # date separator: / or - or .
$t = 2005-10-31 17.11.09; # in-between separator: T or _ or space
$t = 20051031_171109; # time separator: : or .
$t = 20051031171109; # separators may be omitted
$t = 2005/10/31; # date-only is okay
$t = 17:11:09; # time-only is okay
# But not:
$t = 20051031; # date-only without separators
$t = 171109; # time-only without separators
# ...because those look like epoch time numbers.
%strftime works like POSIXs strftime, if you like those %-formats.
$strftime{$format}
$strftime{$format, $unixtime}
$strftime{$format, $sec,$min,$hour, $mday,$mon,$year, $wday,$yday,$isdst}
print "POSIXish: $strftime{%A, %B %d, %Y, 0,0,0,12,11,95,2}n";
print "POSIXish: $strftime{%A, %B %d, %Y, 1054866251}n";
print "POSIXish: $strftime{%A, %B %d, %Y}n"; # current time
%manip works like Date::Manips UnixDate function.
$manip{$format};
$manip{$format, $when};
print "Date::Manip: $manip{%m/%d/%Y}n"; # current time
print "Date::Manip: $manip{%m/%d/%Y,last Tuesday}n";
These can also be used as standalone functions:
use Time::Format qw(time_format time_strftime time_manip);
print "Today is ", time_format(yyyy/mm/dd, $some_time), "n";
print "POSIXish: ", time_strftime(%A %B %d, %Y,$some_time), "n";
print "Date::Manip: ", time_manip(%m/%d/%Y,$some_time), "n";
This module creates global pseudovariables which format dates and times, according to formatting codes you pass to them in strings.
The %time formatting codes are designed to be easy to remember and use, and to take up just as many characters as the output time value whenever possible. For example, the four-digit year code is "yyyy", the three-letter month abbreviation is "Mon".
The nice thing about having a variable-like interface instead of function calls is that the values can be used inside of strings (as well as outside of strings in ordinary expressions). Dates are frequently used within strings (log messages, output, data records, etc.), so having the ability to interpolate them directly is handy.
Perl allows arbitrary expressions within curly braces of a hash, even when that hash is being interpolated into a string. This allows you to do computations on the fly while formatting times and inserting them into strings. See the "yesterday" example above.
The format strings are designed with programmers in mind. What do you need most frequently? 4-digit year, month, day, 24-based hour, minute, second -- usually with leading zeroes. These six are the easiest formats to use and remember in Time::Format: yyyy, mm, dd, hh, mm, ss. Variants on these formats follow a simple and consistent formula. This module is for everyone who is weary of trying to remember strftime(3)s arcane codes, or of endlessly writing $t[4]++; $t[5]+=1900 as you manually format times or dates.
Note that mm (and related codes) are used both for months and minutes. This is a feature. %time resolves the ambiguity by examining other nearby formatting codes. If its in the context of a year or a day, "month" is assumed. If in the context of an hour or a second, "minute" is assumed.
The format strings are not meant to encompass every date/time need ever conceived. But how often do you need the day of the year (strftimes %j) or the week number (strftimes %W)?
For capabilities that %time does not provide, %strftime provides an interface to POSIXs strftime, and %manip provides an interface to the Date::Manip modules UnixDate function.
If the companion module Time::Format_XS is also installed, Time::Format will detect and use it. This will result in a significant speed increase for %time and time_format.
Download (0.038MB)
Added: 2007-07-19 License: Perl Artistic License Price:
830 downloads
Regexp::Common::time 0.01
Regexp::Common::time Perl module contains date and time regexps. more>>
Regexp::Common::time Perl module contains date and time regexps.
SYNOPSIS
use Regexp::Common qw(time);
# Piecemeal, Time::Format-like patterns
$RE{time}{tf}{-pat => pattern}
# Piecemeal, strftime-like patterns
$RE{time}{strftime}{-pat => pattern}
# Match ISO8601-style date/time strings
$RE{time}{iso}
# Fuzzy date patterns
# YEAR/MONTH/DAY
$RE{time}{ymd} # Most flexible
$RE{time}{YMD} # Strictest (equivalent to y4m2d2)
# Other available patterns: y2md, y4md, y2m2d2, y4m2d2
# MONTH/DAY/YEAR (American style)
$RE{time}{mdy} # Most flexible
$RE{time}{MDY} # Strictest (equivalent to m2d2y4)
# Other available patterns: mdy2, mdy4, m2d2y2, m2d2y4
# DAY/MONTH/YEAR (European style)
$RE{time}{mdy} # Most flexible
$RE{time}{MDY} # Strictest (equivalent to d2m2y4)
# Other available patterns: dmy2, dmy4, d2m2y2, d2m2y4
# Fuzzy time pattern
# HOUR/MINUTE/SECOND
$RE{time}{hms} # H: matches 1 or 2 digits; 12 or 24 hours
# M: matches 2 digits.
# S: matches 2 digits; may be omitted
# May be followed by "a", "am", "p.m.", etc.
This module creates regular expressions that can be used for parsing dates and times. See Regexp::Common for a general description of how to use this interface.
Parsing dates is a dirty business. Dates are generally specified in one of three possible orders: year/month/day, month/day/year, and day/month/year. Years can be specified with four digits or with two digits (with assumptions made about the century). Months can be specified as one digit, two digits, as a spelled-out name, or as a three-letter abbreviation. Day numbers can be one digit or two digits, with limits depending on the month (and, in the case of February, even the year). Also, different people use different punctuation for separating the various elements.
A human can easily recognize that "October 21, 2005" and "21.10.05" refer to the same date, but its tricky to get a program to come to the same conclusion. This module attempts to make it possible to do so, with a minimum of difficulty.
If you know the exact format of the data to be matched, use one of the specific, piecemeal pattern builders: tf or strftime. If there is some variability, use one of the fuzzy-matching patterns in the dmy, mdy, or ymd families. If the data are wildly variable, such as raw user input, give up and use the Date::Manip or Date::Parse module.
Time values are generally much simpler to parse than date values. Only one fuzzy pattern is provided, and it should suffice for most needs.
<<lessSYNOPSIS
use Regexp::Common qw(time);
# Piecemeal, Time::Format-like patterns
$RE{time}{tf}{-pat => pattern}
# Piecemeal, strftime-like patterns
$RE{time}{strftime}{-pat => pattern}
# Match ISO8601-style date/time strings
$RE{time}{iso}
# Fuzzy date patterns
# YEAR/MONTH/DAY
$RE{time}{ymd} # Most flexible
$RE{time}{YMD} # Strictest (equivalent to y4m2d2)
# Other available patterns: y2md, y4md, y2m2d2, y4m2d2
# MONTH/DAY/YEAR (American style)
$RE{time}{mdy} # Most flexible
$RE{time}{MDY} # Strictest (equivalent to m2d2y4)
# Other available patterns: mdy2, mdy4, m2d2y2, m2d2y4
# DAY/MONTH/YEAR (European style)
$RE{time}{mdy} # Most flexible
$RE{time}{MDY} # Strictest (equivalent to d2m2y4)
# Other available patterns: dmy2, dmy4, d2m2y2, d2m2y4
# Fuzzy time pattern
# HOUR/MINUTE/SECOND
$RE{time}{hms} # H: matches 1 or 2 digits; 12 or 24 hours
# M: matches 2 digits.
# S: matches 2 digits; may be omitted
# May be followed by "a", "am", "p.m.", etc.
This module creates regular expressions that can be used for parsing dates and times. See Regexp::Common for a general description of how to use this interface.
Parsing dates is a dirty business. Dates are generally specified in one of three possible orders: year/month/day, month/day/year, and day/month/year. Years can be specified with four digits or with two digits (with assumptions made about the century). Months can be specified as one digit, two digits, as a spelled-out name, or as a three-letter abbreviation. Day numbers can be one digit or two digits, with limits depending on the month (and, in the case of February, even the year). Also, different people use different punctuation for separating the various elements.
A human can easily recognize that "October 21, 2005" and "21.10.05" refer to the same date, but its tricky to get a program to come to the same conclusion. This module attempts to make it possible to do so, with a minimum of difficulty.
If you know the exact format of the data to be matched, use one of the specific, piecemeal pattern builders: tf or strftime. If there is some variability, use one of the fuzzy-matching patterns in the dmy, mdy, or ymd families. If the data are wildly variable, such as raw user input, give up and use the Date::Manip or Date::Parse module.
Time values are generally much simpler to parse than date values. Only one fuzzy pattern is provided, and it should suffice for most needs.
Download (0.035MB)
Added: 2007-08-07 License: Perl Artistic License Price:
808 downloads
Text::MetaText 0.22
Text::MetaText is a Perl extension implementing meta-language for processing template text files. more>>
Text::MetaText is a Perl extension implementing meta-language for processing "template" text files.
SYNOPSIS
use Text::MetaText;
my $mt = Text::MetaText->new();
# process file content or text string
print $mt->process_file($filename, %vardefs);
print $mt->process_text($textstring, %vardefs);
# pre-declare a BLOCK for subsequent INCLUDE
$mt->declare($textstring, $blockname);
$mt->declare(@content, $blockname);
SUMMARY OF METATEXT DIRECTIVES
%% DEFINE
variable1 = value # define variable(s)
variable2 = "quoted value"
%%
%% SUBST variable %% # insert variable value
%% variable %% # short form of above
%% BLOCK blockname %% # define a block blockname
block text...
%% ENDBLOCK %%
%% INCLUDE blockname %% # include blockname block text
%% INCLUDE filename %% # include external file filename
%% INCLUDE file_or_block # a more complete example...
variable = value # additional variable definition(s)
if = condition # conditional inclusion
unless = condition # conditional exclusion
format = format_string # printf-like format string with %s
filter = fltname(params) # post-process filter
%%
%% TIME # current system time, as per time(2)
format = format_string # display format, as per strftime(3C)
%%
<<lessSYNOPSIS
use Text::MetaText;
my $mt = Text::MetaText->new();
# process file content or text string
print $mt->process_file($filename, %vardefs);
print $mt->process_text($textstring, %vardefs);
# pre-declare a BLOCK for subsequent INCLUDE
$mt->declare($textstring, $blockname);
$mt->declare(@content, $blockname);
SUMMARY OF METATEXT DIRECTIVES
%% DEFINE
variable1 = value # define variable(s)
variable2 = "quoted value"
%%
%% SUBST variable %% # insert variable value
%% variable %% # short form of above
%% BLOCK blockname %% # define a block blockname
block text...
%% ENDBLOCK %%
%% INCLUDE blockname %% # include blockname block text
%% INCLUDE filename %% # include external file filename
%% INCLUDE file_or_block # a more complete example...
variable = value # additional variable definition(s)
if = condition # conditional inclusion
unless = condition # conditional exclusion
format = format_string # printf-like format string with %s
filter = fltname(params) # post-process filter
%%
%% TIME # current system time, as per time(2)
format = format_string # display format, as per strftime(3C)
%%
Download (0.085MB)
Added: 2007-08-06 License: Perl Artistic License Price:
810 downloads
Tk::Date 0.42
Tk::Date is a date/time widget for perl/Tk. more>>
Tk::Date is a date/time widget for perl/Tk.
SYNOPSIS
use Tk::Date;
$date_widget = $top->Date->pack;
$date_widget->get("%x %X");
Tk::Date implements a date/time widget. There are three ways to input a date:
Using the keyboard to input the digits and the tab key or the mouse pointer to move focus between fields.
Using up and down cursor keys to increment/decrement the date (only with installed Tk::NumEntryPlain widget).
Selecting up and down arrow buttons will increment or decrement the value of the active field (only with installed Tk::FireButton widget).
The Date/Time Format
Unlike Java, Perl does not have a date/time object. However, it is possible to use the unix time (seconds since epoch, that is 1st January 1970) as a replacement. This is limited, since on most architectures, the valid range is between 14th December 1901 and 19th January 2038. For other dates, it is possible to use a hash notation:
{ y => year,
m => month,
d => day,
H => hour,
M => minute,
S => second }
The abbreviations are derivated from the format letters of strftime. Note that year is the full year (1998 instead of 98) and month is the real month number, as opposed to the output of localtime(), where the month is subtracted by one.
In this document, the first method will be referred as unixtime and the second method as datehash.
STANDARD OPTIONS
Tk::Date descends from Frame and inherits all of its options.
-orient
Specified orientation of the increment and decrements buttons. May be vertical (default) or horizontal.
<<lessSYNOPSIS
use Tk::Date;
$date_widget = $top->Date->pack;
$date_widget->get("%x %X");
Tk::Date implements a date/time widget. There are three ways to input a date:
Using the keyboard to input the digits and the tab key or the mouse pointer to move focus between fields.
Using up and down cursor keys to increment/decrement the date (only with installed Tk::NumEntryPlain widget).
Selecting up and down arrow buttons will increment or decrement the value of the active field (only with installed Tk::FireButton widget).
The Date/Time Format
Unlike Java, Perl does not have a date/time object. However, it is possible to use the unix time (seconds since epoch, that is 1st January 1970) as a replacement. This is limited, since on most architectures, the valid range is between 14th December 1901 and 19th January 2038. For other dates, it is possible to use a hash notation:
{ y => year,
m => month,
d => day,
H => hour,
M => minute,
S => second }
The abbreviations are derivated from the format letters of strftime. Note that year is the full year (1998 instead of 98) and month is the real month number, as opposed to the output of localtime(), where the month is subtracted by one.
In this document, the first method will be referred as unixtime and the second method as datehash.
STANDARD OPTIONS
Tk::Date descends from Frame and inherits all of its options.
-orient
Specified orientation of the increment and decrements buttons. May be vertical (default) or horizontal.
Download (0.018MB)
Added: 2006-06-12 License: Perl Artistic License Price:
1230 downloads
Simple PHP Calendar 1.11
Simple PHP Calendar is a a simple, extensible PHP calendar class. more>>
Simple PHP Calendar is a a simple, extensible PHP calendar class. The project focuses exclusively on generating an HTML representation for a given month. It is meant to be easily extended for use in other applications, such as input widgets for forms, or full event calendaring applications. Its output is completely customizable via CSS.
A simple example
After downloading the class and including it in your PHP script, youre ready to start using it. The constructor requires two paramets, a year and month. The following code produces a very plain looking calendar.
1 require_once( class.Calendar.php );
2 $cal = new Calendar (2004, 3 );
3 echo "".$cal->getFullMonthName()."";
4 echo $cal->display();
Customizing the display
You can use two methods to change how the calendar is displayed. Use setTableWidth to define how wide to make the table, in pixels or as a percentage of the screen. Use setDayNameFormat to change how weekdays are displayed in the header row using strftime formats.
1 require_once(class.Calendar.php);
2 $calendar = new Calendar (2004, 4);
3 $calendar->setTableWidth(50%);
4 $calendar->setDayNameFormat(%A);
5 echo "".$calendar->getBriefMonthName().";
6 echo $calendar->display();
Final Example
You can use CSS selectors to control the formatting of all aspects of the calendar, including adding borders and how empty boxes display. Lets wrap our talbe in a div named calendar and use the following styles.
/* overall table */
#calendar table {
border:1px solid #fff;
padding: 0;
margin:20px;
}
/* the day headers across the top */
#calendar th {
background: #565;
color: #fff;
margin: 3px;
padding: 2px 5px;
}
/* how days this month will look, make dates appear in top right */
#calendar td {
background: #eee;
color: #000;
padding: 2px;
margin:0;
height:60px;
text-align:right;
vertical-align:top;
border:1px solid #fff;
}
/* these are the days falling outside this month */
#calendar td.notInMonth {
background: #999;
}
Enhancements:
- The documentation has been polished.
- An example has been added for extending the class to customize how a calendar grid will display.
<<lessA simple example
After downloading the class and including it in your PHP script, youre ready to start using it. The constructor requires two paramets, a year and month. The following code produces a very plain looking calendar.
1 require_once( class.Calendar.php );
2 $cal = new Calendar (2004, 3 );
3 echo "".$cal->getFullMonthName()."";
4 echo $cal->display();
Customizing the display
You can use two methods to change how the calendar is displayed. Use setTableWidth to define how wide to make the table, in pixels or as a percentage of the screen. Use setDayNameFormat to change how weekdays are displayed in the header row using strftime formats.
1 require_once(class.Calendar.php);
2 $calendar = new Calendar (2004, 4);
3 $calendar->setTableWidth(50%);
4 $calendar->setDayNameFormat(%A);
5 echo "".$calendar->getBriefMonthName().";
6 echo $calendar->display();
Final Example
You can use CSS selectors to control the formatting of all aspects of the calendar, including adding borders and how empty boxes display. Lets wrap our talbe in a div named calendar and use the following styles.
/* overall table */
#calendar table {
border:1px solid #fff;
padding: 0;
margin:20px;
}
/* the day headers across the top */
#calendar th {
background: #565;
color: #fff;
margin: 3px;
padding: 2px 5px;
}
/* how days this month will look, make dates appear in top right */
#calendar td {
background: #eee;
color: #000;
padding: 2px;
margin:0;
height:60px;
text-align:right;
vertical-align:top;
border:1px solid #fff;
}
/* these are the days falling outside this month */
#calendar td.notInMonth {
background: #999;
}
Enhancements:
- The documentation has been polished.
- An example has been added for extending the class to customize how a calendar grid will display.
Download (0.002MB)
Added: 2007-01-24 License: GPL (GNU General Public License) Price:
1013 downloads
DateTime::Format::Strptime 1.0700
DateTime::Format::Strptime is a Perl module to parse and format strp and strf time patterns. more>>
DateTime::Format::Strptime is a Perl module to parse and format strp and strf time patterns.
SYNOPSIS
use DateTime::Format::Strptime;
my $Strp = new DateTime::Format::Strptime(
pattern => %T,
locale => en_AU,
time_zone => Australia/Melbourne,
);
my $dt = $Strp->parse_datetime(23:16:42);
$Strp->format_datetime($dt);
# 23:16:42
# Croak when things go wrong:
my $Strp = new DateTime::Format::Strptime(
pattern => %T,
locale => en_AU,
time_zone => Australia/Melbourne,
on_error => croak,
);
$newpattern = $Strp->pattern(%Q);
# Unidentified token in pattern: %Q in %Q at line 34 of script.pl
# Do something else when things go wrong:
my $Strp = new DateTime::Format::Strptime(
pattern => %T,
locale => en_AU,
time_zone => Australia/Melbourne,
on_error => &phone_police,
);
This module implements most of strptime(3), the POSIX function that is the reverse of strftime(3), for DateTime. While strftime takes a DateTime and a pattern and returns a string, strptime takes a string and a pattern and returns the DateTime object associated.
<<lessSYNOPSIS
use DateTime::Format::Strptime;
my $Strp = new DateTime::Format::Strptime(
pattern => %T,
locale => en_AU,
time_zone => Australia/Melbourne,
);
my $dt = $Strp->parse_datetime(23:16:42);
$Strp->format_datetime($dt);
# 23:16:42
# Croak when things go wrong:
my $Strp = new DateTime::Format::Strptime(
pattern => %T,
locale => en_AU,
time_zone => Australia/Melbourne,
on_error => croak,
);
$newpattern = $Strp->pattern(%Q);
# Unidentified token in pattern: %Q in %Q at line 34 of script.pl
# Do something else when things go wrong:
my $Strp = new DateTime::Format::Strptime(
pattern => %T,
locale => en_AU,
time_zone => Australia/Melbourne,
on_error => &phone_police,
);
This module implements most of strptime(3), the POSIX function that is the reverse of strftime(3), for DateTime. While strftime takes a DateTime and a pattern and returns a string, strptime takes a string and a pattern and returns the DateTime object associated.
Download (0.025MB)
Added: 2007-05-17 License: Perl Artistic License Price:
890 downloads
httplog 2.1
httplog is an apache log rollover program w/strftime(3) filename support. more>>
httplog is a replacement for Apaches rotatelogs and Andrew Fords chronolog. It allows you to specify a logfile using strftime paramaters in the filename to act as a template.
This means that the logs in your logfiles will also be sorted according to the filename. For example, if you specify a logfile of /var/log/http%Y%m%d.log, a new log file would be generated each day, with content for only that one day.
It also supports compression of logfiles using gzip, and many other useful functions.
It takes one argument at the command line, the path to a logfile as a template.
The template pathname can use any valid special characters permitted in strftime(3). Other optional arguments can be appended to the command line.
If you want to have httplog run as a different user and/or group (instead of running as root - possible security risks), you can use the `-u and `-g to have httplog run as that user and/or group.
You can also specify `-b to have httplog use a custom buffer size for memory storage of log data, rather than the default value of just line buffering mode (flushes data per newline).
If you want to have your logfiles gzipped because of size constraints, you can now use the `-z option to have httplog gzip all logfiles once its done writing all data to them (when a rollover period hits and a new logfile is to be created).
You may have a symlink to the currently active logfile by using the `-s option and specifying a filename to be used as the symlink.
This program makes Apache act similar to Microsofts IIS webserver in its logging style (as opposed to every logfile entry in one single huge logfile). This allows you to easily maintain your webserver logfiles for statistics packages in an easily organizable manner without user intervention.
Because of the buffer option added since v1.5, httplog may also be usefull for extremely large sites that get thousands of hits per second, and typically disable logging to save their hard drives from dying.
The buffer size option can be used to create an extremely large buffer in ram so that logfiles would not be flushed as often as if it were in line buffering mode, and in essence, could prolong the life of your valuable drives by decreasing their activity.
Enhancements:
- Removed a couple of lines of code that could cause segfaults if errors were imminent while opening new a file or allocating the buffer memory
<<lessThis means that the logs in your logfiles will also be sorted according to the filename. For example, if you specify a logfile of /var/log/http%Y%m%d.log, a new log file would be generated each day, with content for only that one day.
It also supports compression of logfiles using gzip, and many other useful functions.
It takes one argument at the command line, the path to a logfile as a template.
The template pathname can use any valid special characters permitted in strftime(3). Other optional arguments can be appended to the command line.
If you want to have httplog run as a different user and/or group (instead of running as root - possible security risks), you can use the `-u and `-g to have httplog run as that user and/or group.
You can also specify `-b to have httplog use a custom buffer size for memory storage of log data, rather than the default value of just line buffering mode (flushes data per newline).
If you want to have your logfiles gzipped because of size constraints, you can now use the `-z option to have httplog gzip all logfiles once its done writing all data to them (when a rollover period hits and a new logfile is to be created).
You may have a symlink to the currently active logfile by using the `-s option and specifying a filename to be used as the symlink.
This program makes Apache act similar to Microsofts IIS webserver in its logging style (as opposed to every logfile entry in one single huge logfile). This allows you to easily maintain your webserver logfiles for statistics packages in an easily organizable manner without user intervention.
Because of the buffer option added since v1.5, httplog may also be usefull for extremely large sites that get thousands of hits per second, and typically disable logging to save their hard drives from dying.
The buffer size option can be used to create an extremely large buffer in ram so that logfiles would not be flushed as often as if it were in line buffering mode, and in essence, could prolong the life of your valuable drives by decreasing their activity.
Enhancements:
- Removed a couple of lines of code that could cause segfaults if errors were imminent while opening new a file or allocating the buffer memory
Download (0.013MB)
Added: 2005-04-25 License: Free To Use But Restricted Price:
1644 downloads
Test::Reporter::Date::Format 1.27
Test::Reporter::Date::Format Perl module contains date formating subroutines. more>>
Test::Reporter::Date::Format Perl module contains date formating subroutines.
SYNOPSIS
use Test::Reporter::Date::Format;
@lt = localtime(time);
print time2str($template, time);
print strftime($template, @lt);
print time2str($template, time, $zone);
print strftime($template, @lt, $zone);
print ctime(time);
print asctime(@lt);
print ctime(time, $zone);
print asctime(@lt, $zone);
This module provides routines to format dates into ASCII strings. They correspond to the C library routines strftime and ctime.
time2str(TEMPLATE, TIME [, ZONE])
time2str converts TIME into an ASCII string using the conversion specification given in TEMPLATE. ZONE if given specifies the zone which the output is required to be in, ZONE defaults to your current zone.
strftime(TEMPLATE, TIME [, ZONE])
strftime is similar to time2str with the exception that the time is passed as an array, such as the array returned by localtime.
ctime(TIME [, ZONE])
ctime calls time2str with the given arguments using the conversion specification "%a %b %e %T %Yn"
asctime(TIME [, ZONE])
asctime calls time2str with the given arguments using the conversion specification "%a %b %e %T %Yn"
<<lessSYNOPSIS
use Test::Reporter::Date::Format;
@lt = localtime(time);
print time2str($template, time);
print strftime($template, @lt);
print time2str($template, time, $zone);
print strftime($template, @lt, $zone);
print ctime(time);
print asctime(@lt);
print ctime(time, $zone);
print asctime(@lt, $zone);
This module provides routines to format dates into ASCII strings. They correspond to the C library routines strftime and ctime.
time2str(TEMPLATE, TIME [, ZONE])
time2str converts TIME into an ASCII string using the conversion specification given in TEMPLATE. ZONE if given specifies the zone which the output is required to be in, ZONE defaults to your current zone.
strftime(TEMPLATE, TIME [, ZONE])
strftime is similar to time2str with the exception that the time is passed as an array, such as the array returned by localtime.
ctime(TIME [, ZONE])
ctime calls time2str with the given arguments using the conversion specification "%a %b %e %T %Yn"
asctime(TIME [, ZONE])
asctime calls time2str with the given arguments using the conversion specification "%a %b %e %T %Yn"
Download (0.023MB)
Added: 2007-07-24 License: Perl Artistic License Price:
822 downloads
Userinfo 2.2
Userinfo is a console utility to display a variety of information about a local user. more>>
Userinfo is a console utility to display a variety of information about a local user. The project uses loadable modules to perform different tasks which separate the output with a field deliminator.
Some may find it useful in shell scripts to gather information which might be tedious by other methods. It has been tested to run on Linux, FreeBSD, NetBSD, and Solaris.
Usage: ./ui [-vhVL] [-c < filename >] [-t fmt] [-m c] [-F c] [-d]
[[-xX] -O < module1 > [options] [-- [-xX] -O < module2 > [...]]]
[- | username | -f filename] [...]
-d Load the default modules (passwd.so, mail.so, and login.so).
-c Read a configuration file. Can be used more than once.
-O Load a module. Can be used more than once.
-x Chain module1s output to module2s input.
-X Dont output module1s info, only chain it.
-F c Separate output with the specified character (:).
-m c Separate multi-string values with the specified character (,).
-t tf strftime(3) time format (%s).
-f Users are the owners of the specified files.
-L Follow symbolic links.
-v Verbose output when possible (twice for all modules).
-h This help text.
-V Version information
Enhancements:
- The follow symbolic links option was changed from -l to -L.
- The users idle time from the login module is displayed as seconds rather than minutes.
<<lessSome may find it useful in shell scripts to gather information which might be tedious by other methods. It has been tested to run on Linux, FreeBSD, NetBSD, and Solaris.
Usage: ./ui [-vhVL] [-c < filename >] [-t fmt] [-m c] [-F c] [-d]
[[-xX] -O < module1 > [options] [-- [-xX] -O < module2 > [...]]]
[- | username | -f filename] [...]
-d Load the default modules (passwd.so, mail.so, and login.so).
-c Read a configuration file. Can be used more than once.
-O Load a module. Can be used more than once.
-x Chain module1s output to module2s input.
-X Dont output module1s info, only chain it.
-F c Separate output with the specified character (:).
-m c Separate multi-string values with the specified character (,).
-t tf strftime(3) time format (%s).
-f Users are the owners of the specified files.
-L Follow symbolic links.
-v Verbose output when possible (twice for all modules).
-h This help text.
-V Version information
Enhancements:
- The follow symbolic links option was changed from -l to -L.
- The users idle time from the login module is displayed as seconds rather than minutes.
Download (0.35MB)
Added: 2007-03-22 License: GPL (GNU General Public License) Price:
949 downloads
orbitclock 0.3
orbitclock is a pseudo-Star-Trek-style desktop clock. more>>
orbitclock displays a small circular representation of a clock in a pseudo-Star-Trek style.
Nifty little Star-Trek-ish clock display. Resizable, but some of the parameters in the code may need to be tweaked to make it look good at other sizes.
Feel free to play with the parameters at the top of draw() and the colors. Let me know if you get something niftier.
Usage:
orbitclock [options]
-geometry WxH[+X+Y] set window geometry
-bg < color name > background color
-fg < color name > foreground 1 color (tick)
-fg2 < color name > foreground 2 color (block)
-rings < hms|smh|etc. > ordering of rings from inside out (default hms)
-font < font > font to use for date (implies -date)
-date[=optional format] draw date in center, strftime format string literal n causes line break example: -date="%m/%d/%Yn%H:%M:%S" equals sign is REQUIRED, dont ask me why.
<<lessNifty little Star-Trek-ish clock display. Resizable, but some of the parameters in the code may need to be tweaked to make it look good at other sizes.
Feel free to play with the parameters at the top of draw() and the colors. Let me know if you get something niftier.
Usage:
orbitclock [options]
-geometry WxH[+X+Y] set window geometry
-bg < color name > background color
-fg < color name > foreground 1 color (tick)
-fg2 < color name > foreground 2 color (block)
-rings < hms|smh|etc. > ordering of rings from inside out (default hms)
-font < font > font to use for date (implies -date)
-date[=optional format] draw date in center, strftime format string literal n causes line break example: -date="%m/%d/%Yn%H:%M:%S" equals sign is REQUIRED, dont ask me why.
Download (0.004MB)
Added: 2005-05-19 License: Public Domain Price:
1619 downloads
Metalog 0.8 RC4
Metalog provides simple and flexible replacement for syslogd and klogd. more>>
Metalog provides simple and flexible replacement for syslogd and klogd.
Metalog is a modern replacement for syslogd and klogd. The logged messages can be dispatched according to their facility, urgency, program name, and/or Perl-compatible regular expressions.
Log files can be automatically rotated when they exceed a certain size or age. External shell scripts (e.g., mail) can be launched when specific patterns are found.
Metalog is easier to configure than syslogd and syslog-ng, accepts an unlimited number of rules, and has (switchable) memory bufferization for maximal performance.
Enhancements:
- fix typo in previous change when checking the return of strftime()
<<lessMetalog is a modern replacement for syslogd and klogd. The logged messages can be dispatched according to their facility, urgency, program name, and/or Perl-compatible regular expressions.
Log files can be automatically rotated when they exceed a certain size or age. External shell scripts (e.g., mail) can be launched when specific patterns are found.
Metalog is easier to configure than syslogd and syslog-ng, accepts an unlimited number of rules, and has (switchable) memory bufferization for maximal performance.
Enhancements:
- fix typo in previous change when checking the return of strftime()
Download (0.10MB)
Added: 2007-04-30 License: GPL (GNU General Public License) Price:
907 downloads
AxKit::XSP::ESQL 1.4
AxKit::XSP::ESQL is an Extended SQL taglib for AxKit eXtensible Server Pages. more>>
AxKit::XSP::ESQL is an Extended SQL taglib for AxKit eXtensible Server Pages.
SYNOPSIS
Add the esql: namespace to your XSP < xsp:page > tag:
< xsp:page
language="Perl"
xmlns:xsp="http://apache.org/xsp/core/v1"
xmlns:esql="http://apache.org/xsp/SQL/v2"
>
And add this taglib to AxKit (via httpd.conf or .htaccess):
AxAddXSPTaglib AxKit::XSP::ESQL
This tag library provides extensive support for executing SQL statements from within XSP. This tag library is the same as the Cocoon ESQL taglib.
TAG REFERENCE
Note that below we use the esql: prefix as a convention, however you can use whatever prefix you like provided it is mapped to the appropriate namespace.
< esql:connection>
parent: none
This is the required wrapper element that declares your connection.
< esql:driver>
parent: < esql:connection>
The contents of this element define the DBI driver to be used. For example, Pg, Sybase, Oracle.
You can also add an optional attribute: transactions=no to the driver element, to indicate that this driver does not support transactions (or just that you dont want to use transactions).
< esql:dburl>
parent: < esql:connection>
The name of this tag is a hang-over from the Cocoon (Java) version. In the AxKit version this is simply anything that goes after the driver in the connection string. So for PostgreSQL you might have in here dbname=axkit, to connect to the "axkit" database. The full connect string is constructed as follows:
"dbi:$driver" . ($dburl ? ":$dburl" : "")
See your DBD driver documentation for more details on what is valid for the connection string.
< esql:username>
parent: < esql:connection>
The username to connect to the database with.
< esql:password>
parent: < esql:connection>
The password to use to connect to the database.
< esql:execute-query>
parent: < esql:connection>
This tag is a wrapper tag around queries. You may have as many queries as you like within a single < esql:connection> tag.
< esql:skip-rows>
parent: < esql:execute-query>
The contents of this tag (which may be an < xsp:expr>) define a number of rows to skip forward in the result set.
< esql:max-rows>
parent: < esql:execute-query>
The maximum number of rows to return.
< esql:query>
parent: < esql:execute-query>
The contents of this tag define the query to be executed.
< esql:parameter>
parent: < esql:query>
This tag can be put in your SQL query everywhere you might put a ? in your SQL in DBI. ESQL is intelligent enough to create a cached statement when you do this, and only execute your code when necessary. You put an expression (or another taglib) within the parameter tag (see the example below).
< esql:results>
parent: < esql:execute-query>
The contents of this tag are "executed" whenever the query returns some results.
< esql:row-results>
parent: < esql:results>
The contents of this tag are "executed" for each row of the results
< esql:get-columns>
parent: < esql:row-results>
This tag gets all of the columns in the current row, and outputs them as < column_name>value< /column_name>. If you specify an attribute tag-case="upper", all columns are upper case. Alternatively, "lower" gives you all tags in lower case. An ancestor attribute is also allowed, see "Nested Results" below for more details.
get-*
parent: < esql:row-results>
These are:
get-column
get-string
get-boolean
get-double
get-float
get-int
get-long
get-short
(and more below)
Each of these takes either an attribute column="name", or a child tag, < esql:column> which gives the column name. Alternatively either the attribute or child element can be an integer (starting at 1) specifying the column number.
Also allowed is an ancestor attribute, which is an integer (default 0), which indicates how far up the nested results you go. See Nested Results below.
< esql:get-date>, < esql:get-time>, < esql:get-timestamp>
parent: < esql:row-results>
These tags are the same as get-* above, except they also take a format="..." attribute, which contains a strftime formatting string.
< esql:get-xml>
parent: < esql:row-results>
Again the same as get-* above. This tag assumes the contents of the column are valid XML, and appends that XML into the result tree.
< esql:get-row-position>
parent: < esql:row-results>
Gets the current row number. Optional ancestor attribute.
< esql:get-column-name>
parent: < esql:row-results>
Gets the column name indicated by the numbered column in the column="..." attribute, or the child < esql:column> element. The attribute/child can actually be a string (name), but then what is the point of that?
< esql:get-column-label>
parent: < esql:row-results>
Gets the label of the column. This is a hang-over from the Cocoon java implementation where sadly nobody seems to know what label is compared with name. In this case, get-column-name is always lower case, whereas get-column-label is returned in the case that the DBD driver returns it as.
< esql:get-column-type-name>
parent: < esql:row-results>
Returns the TYPE_NAME of the column indicated as other get-* elements. See the DBI docs for more details.
< esql:no-results>
parent: < esql:execute-query>
The contents of this element are executed when the SQL returned no rows.
< esql:update-results>
parent: < esql:execute-query>
The contents of this element are executed when the SQL was an update statement. The number of rows updated are in the $rv variable.
<<lessSYNOPSIS
Add the esql: namespace to your XSP < xsp:page > tag:
< xsp:page
language="Perl"
xmlns:xsp="http://apache.org/xsp/core/v1"
xmlns:esql="http://apache.org/xsp/SQL/v2"
>
And add this taglib to AxKit (via httpd.conf or .htaccess):
AxAddXSPTaglib AxKit::XSP::ESQL
This tag library provides extensive support for executing SQL statements from within XSP. This tag library is the same as the Cocoon ESQL taglib.
TAG REFERENCE
Note that below we use the esql: prefix as a convention, however you can use whatever prefix you like provided it is mapped to the appropriate namespace.
< esql:connection>
parent: none
This is the required wrapper element that declares your connection.
< esql:driver>
parent: < esql:connection>
The contents of this element define the DBI driver to be used. For example, Pg, Sybase, Oracle.
You can also add an optional attribute: transactions=no to the driver element, to indicate that this driver does not support transactions (or just that you dont want to use transactions).
< esql:dburl>
parent: < esql:connection>
The name of this tag is a hang-over from the Cocoon (Java) version. In the AxKit version this is simply anything that goes after the driver in the connection string. So for PostgreSQL you might have in here dbname=axkit, to connect to the "axkit" database. The full connect string is constructed as follows:
"dbi:$driver" . ($dburl ? ":$dburl" : "")
See your DBD driver documentation for more details on what is valid for the connection string.
< esql:username>
parent: < esql:connection>
The username to connect to the database with.
< esql:password>
parent: < esql:connection>
The password to use to connect to the database.
< esql:execute-query>
parent: < esql:connection>
This tag is a wrapper tag around queries. You may have as many queries as you like within a single < esql:connection> tag.
< esql:skip-rows>
parent: < esql:execute-query>
The contents of this tag (which may be an < xsp:expr>) define a number of rows to skip forward in the result set.
< esql:max-rows>
parent: < esql:execute-query>
The maximum number of rows to return.
< esql:query>
parent: < esql:execute-query>
The contents of this tag define the query to be executed.
< esql:parameter>
parent: < esql:query>
This tag can be put in your SQL query everywhere you might put a ? in your SQL in DBI. ESQL is intelligent enough to create a cached statement when you do this, and only execute your code when necessary. You put an expression (or another taglib) within the parameter tag (see the example below).
< esql:results>
parent: < esql:execute-query>
The contents of this tag are "executed" whenever the query returns some results.
< esql:row-results>
parent: < esql:results>
The contents of this tag are "executed" for each row of the results
< esql:get-columns>
parent: < esql:row-results>
This tag gets all of the columns in the current row, and outputs them as < column_name>value< /column_name>. If you specify an attribute tag-case="upper", all columns are upper case. Alternatively, "lower" gives you all tags in lower case. An ancestor attribute is also allowed, see "Nested Results" below for more details.
get-*
parent: < esql:row-results>
These are:
get-column
get-string
get-boolean
get-double
get-float
get-int
get-long
get-short
(and more below)
Each of these takes either an attribute column="name", or a child tag, < esql:column> which gives the column name. Alternatively either the attribute or child element can be an integer (starting at 1) specifying the column number.
Also allowed is an ancestor attribute, which is an integer (default 0), which indicates how far up the nested results you go. See Nested Results below.
< esql:get-date>, < esql:get-time>, < esql:get-timestamp>
parent: < esql:row-results>
These tags are the same as get-* above, except they also take a format="..." attribute, which contains a strftime formatting string.
< esql:get-xml>
parent: < esql:row-results>
Again the same as get-* above. This tag assumes the contents of the column are valid XML, and appends that XML into the result tree.
< esql:get-row-position>
parent: < esql:row-results>
Gets the current row number. Optional ancestor attribute.
< esql:get-column-name>
parent: < esql:row-results>
Gets the column name indicated by the numbered column in the column="..." attribute, or the child < esql:column> element. The attribute/child can actually be a string (name), but then what is the point of that?
< esql:get-column-label>
parent: < esql:row-results>
Gets the label of the column. This is a hang-over from the Cocoon java implementation where sadly nobody seems to know what label is compared with name. In this case, get-column-name is always lower case, whereas get-column-label is returned in the case that the DBD driver returns it as.
< esql:get-column-type-name>
parent: < esql:row-results>
Returns the TYPE_NAME of the column indicated as other get-* elements. See the DBI docs for more details.
< esql:no-results>
parent: < esql:execute-query>
The contents of this element are executed when the SQL returned no rows.
< esql:update-results>
parent: < esql:execute-query>
The contents of this element are executed when the SQL was an update statement. The number of rows updated are in the $rv variable.
Download (0.006MB)
Added: 2007-06-11 License: Perl Artistic License Price:
866 downloads
Secleted [ 0 ] software to compare
- Page: 1 of 2
- 1
- 2
Copyright Notice:
Software piracy is theft, Using crack, password, serial numbers, registration codes, key generators is illegal and prevent future software development. The above strftime search only lists software in full, demo and trial versions for free download. Download links are directly from our mirror sites or publisher sites, torrent files or links from rapidshare.com, yousendit.com or megaupload.com are not allowed