home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book HomeJava and XSLTSearch this book

8.223. Time::gmtime

Replaces Perl's core gmtime function with a version that returns Time::tm objects. Exports two functions.

gmctime

$gmc = gmctime(  )

Overrides the core gmtime function in scalar context; returns a string with the date and time:

use Time::gmtime;
$gmc = gmctime( );
print $gmc;

Then the output of the print command looks like:

Thu Apr 9 18:15:06 1998
gmtime

$gm = gmtime(  )

Overrides the core gmtime function. The Time::tm object returned has methods with the same names as the structure fields they return. That is, to return the field mon, use the mon method:

use Time::gmtime;
$gm = gmtime( );
print $gm->mon;

The field names (and therefore the method names) are the same as the names of the fields in the tm structure in the C file time.h: sec, min, hour, mday, mon, year, wday, yday, and isdst. You can access the fields either with the methods or by importing the fields into your namespace with the :FIELDS import tag and prepending tm_ to the method name (for example, $tm_mon).



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.