Hill, Ronald schreef: > I wanted to ask the group about an idea I have for an article for the > perl review. This would be a beginner/newbie article on basic usage > of DateTime. I have put together some ideas starting with getting things > into/out of DateTime and comparing dates. Any other ideas for the article? > I want to keep is simple as possible.
Here are some comments; of course, feel free to ignore everything I say. * I would remove the from_epoch description. It is not that important for beginners, especially because the particular example you give (from_epoch => time()) doesn't add anything to DateTime->now. * Keep the first example as simple as possible: remove the nanosecond parameter, and possibly the timezone. * Show a few output methods; ymd(), mdy() and dmy(); hms(); datetime() come to mind. * When you introduce timezones, show a conversion like $dt1 = DateTime->new( year => 2003, month => 8, day => 26, hour => 21, time_zone => 'America/Chicago' ); # What time is it in Helsinki, when it is 9pm in Chicago? $dt2 = $dt1->clone->set_time_zone( 'Europe/Helsinki' ); print $dt2->datetime, "\n"; * You might want to show some date math: $dt1 = DateTime->now(); # One week ago: $dt2 = $dt1->clone->subtract( weeks => 1); print $dt2->datetime, "\n"; * "One of the big problems in handling dates is Summertime (aka Daylight Saving Time). DateTime can do it all for you." $dt1->DateTime->new( .. insert date just before DST here .. ); $dt1->add( hours => 10 ); print $dt1->datetime, "\n"; prints "2003-03-xxT11:00:00"! And then say something like "DateTime knows the DST rules of avery country in the world." * When you're showing the Fromat modules, it might be more instructive to convert to another format, instead of parsing and formatting a HTTP date. I suggest you use DT::F::ISO8601 or ::MySQL->format_datetime. Eugene