A useful combination of modules to have around is Time::Zone and Time::Format. Time::Zone offers methods such as figuring the time offset (from GMT) of a time zone, and Time::Format makes it easy to get a timestamp formatted how you want it--not localtime's format.
For example, if you want to see the current date/time on the Pacific coast of North America:
Code:
use Time::Format qw(time_format);<br />use Time::Zone;<br /><br /># Get the current GM time.<br />my $time = time();<br /><br /># Offset for PST (Pacific Standard Time).<br />my $offset = tz_offset ('PST');<br />$time += $offset; # modify GM time with this offset.<br /><br /># Get the time stamp!<br />my $stamp = time_format ('Weekday, Month d yyyy @ H:mm:ss AM');<br /># might return something like "Saturday, March 26 2005 @ 1:00:21 PM"
So with Time::Zone and Time::Format, you can quickly and easily begin including time zones into your bot. Your user can define their own time zone, and the bot can make changes in its schedule for that user's time (for example, you can make an appointment reminder, or you can always know your user's time -- so if they're online at 1 in the morning the bot can ask if they're tired or not... things like that).
You can download the modules from CPAN (maybe PPM too, haven't really tried). The module page that's probably of more interest is the one for Time::Format, http://search.cpan.org/~roode/Time-Format-1.00/Format.pm, as it has a table of all the "keywords" to be used when getting a time format:
Code:
yyyy 4-digit year<br /> yy 2-digit year<br /><br /> m 1- or 2-digit month, 1-12<br /> mm 2-digit month, 01-12<br /> ?m month with leading space if < 10<br /><br /> Month full month name, mixed-case<br /> MONTH full month name, uppercase<br /> month full month name, lowercase<br /> Mon 3-letter month abbreviation, mixed-case<br /> MON mon ditto, uppercase and lowercase versions<br /><br /> d day number, 1-31<br /> dd day number, 01-31<br /> ?d day with leading space if < 10<br /> th day suffix (st, nd, rd, or th)<br /> TH uppercase suffix<br /><br /> Weekday weekday name, mixed-case<br /> WEEKDAY weekday name, uppercase<br /> weekday weekday name, lowercase<br /> Day 3-letter weekday name, mixed-case<br /> DAY day ditto, uppercase and lowercase versions<br /><br /> h hour, 0-23<br /> hh hour, 00-23<br /> ?h hour, 0-23 with leading space if < 10<br /><br /> H hour, 1-12<br /> HH hour, 01-12<br /> ?H hour, 1-12 with leading space if < 10<br /><br /> m minute, 0-59<br /> mm minute, 00-59<br /> ?m minute, 0-59 with leading space if < 10<br /><br /> s second, 0-59<br /> ss second, 00-59<br /> ?s second, 0-59 with leading space if < 10<br /> mmm millisecond, 000-999<br /> uuuuuu microsecond, 000000-999999<br /><br /> am a.m. The string "am" or "pm" (second form with periods)<br /> pm p.m. same as "am" or "a.m."<br /> AM A.M. same as "am" or "a.m." but uppercase<br /> PM P.M. same as "AM" or "A.M."<br /><br /> tz time zone abbreviation