root/trunk/plagger/lib/Plagger/Date.pm

Revision 2 (checked in by miyagawa, 15 years ago)

import Plagger

  • Property svn:keywords set to Id Revision
Line 
1 package Plagger::Date;
2 use strict;
3 use base qw( DateTime );
4
5 use UNIVERSAL::require;
6
7 sub rebless {
8     my($class, $dt) = @_;
9     bless $dt, $class;
10 }
11
12 sub now {
13     my($class, %opt) = @_;
14     my $self = $class->SUPER::now();
15
16     my $tz = $opt{timezone} || 'local';
17     $self->set_time_zone($tz);
18
19     $self;
20 }
21
22 sub format {
23     my($self, $format) = @_;
24     my $module = "DateTime::Format::$format";
25     $module->require or die $@;
26
27     $module->format_datetime($self);
28 }
29
30 1;
Note: See TracBrowser for help on using the browser.