Lines Matching refs:stamp

65     my $stamp = Timestamp->new($timestamp);
66 ok( $stamp, "created timestamp $n" );
67 is( "$stamp", '2006-08-04 21:22:23', "timestamp $n string" );
68 is( $stamp->timestamp(), '2006-08-04 21:22:23', "timestamp() $n" );
69 is( $stamp->date(), '2006-08-04', "date() $n" );
70 is( $stamp->year(), '2006', "year() $n" );
71 is( $stamp->month(), '8', "month() $n" );
72 is( $stamp->day(), '4', "day() $n" );
73 is( $stamp->time(), '21:22:23', "time() $n" );
74 is( $stamp->hours(), '21', "hours() $n" );
75 is( $stamp->minutes(), '22', "hours() $n" );
76 is( $stamp->seconds(), '23', "minutes() $n" );
111 my $stamp = Timestamp->new('2006-03-19 04:20:42');
112 ok( $stamp, 'created new timestamp' );
113 ok( $stamp->year(2007), 'changed year' );
114 is( $stamp, '2007-03-19 04:20:42', 'new year set' );
115 ok( $stamp->month(04), 'changed month' );
116 is( $stamp, '2007-04-19 04:20:42', 'new month set' );
117 ok( $stamp->day(20), 'changed year' );
118 is( $stamp, '2007-04-20 04:20:42', 'new day set' );
119 ok( $stamp->hours(05), 'changed hours' );
120 is( $stamp, '2007-04-20 05:20:42', 'new hours set' );
121 ok( $stamp->minutes(21), 'changed minutes' );
122 is( $stamp, '2007-04-20 05:21:42', 'new minutes set' );
123 ok( $stamp->seconds(43), 'changed seconds' );
124 is( $stamp, '2007-04-20 05:21:43', 'new seconds set' );
130 is( $stamp->adjust( year => 1, month => 2, day => 3,
131 hours => 4, minutes => 5, seconds => 6 ), $stamp, 'adjusted time' );
132 is( $stamp, '2008-06-23 09:26:49', 'time adjusted' );
135 is( $stamp->adjust( seconds => 12 ), '2008-06-23 09:27:01', 'rolled over minute' );
136 is( $stamp->adjust( minutes => 32, seconds => 63 ), '2008-06-23 10:00:04', 'rolled over hour' );
137 is( $stamp->adjust( hours => 20 ), '2008-06-24 06:00:04', 'rolled over day' );
138 is( $stamp->adjust( day => 8 ), '2008-07-02 06:00:04', 'rolled over 30 day month' );
139 is( $stamp->adjust( days => 30 ), '2008-08-01 06:00:04', 'rolled over 31 day month' );
142 is( $stamp->adjust("3 days"), '2008-08-04 06:00:04', 'adjust 3 days' );
143 #is( $stamp->adjust("-1 month"), '2008-07-04 06:00:04', 'adjust -1 month' );
144 is( $stamp->adjust(month => -1), '2008-07-04 06:00:04', 'adjust -1 month' );
145 is( $stamp->adjust("-4 days"), '2008-06-30 06:00:04', 'adjust -4 days' );
153 $stamp = Timestamp('2008-08-01 06:00:04');
155 ok( ! $stamp->leap_year(1900), 'not leap year 1900' );
156 ok( ! $stamp->leap_year(1999), 'not leap year 1999' );
157 ok( $stamp->leap_year(2000), 'leap year 2000' );
158 ok( ! $stamp->leap_year(2001), 'not leap year 2001' );
159 ok( ! $stamp->leap_year(2002), 'not leap year 2002' );
160 ok( ! $stamp->leap_year(2003), 'not leap year 2003' );
161 ok( $stamp->leap_year(2004), 'leap year 2004' );
162 ok( ! $stamp->leap_year(2005), 'leap year 2005' );
164 is( $stamp->days_in_month(), 31, 'august has 31 days' );
165 is( $stamp->days_in_month(1), 31, 'january has 31 days' );
166 is( $stamp->days_in_month(2, 2003), 28, 'january has 28 days in 2003' );
167 is( $stamp->days_in_month(2, 2004), 29, 'january has 29 days in 2004' );
168 is( $stamp->days_in_month(3), 31, 'march has 31 days' );
169 is( $stamp->days_in_month(4), 30, 'april has 30 days' );
170 is( $stamp->days_in_month(5), 31, 'may has 31 days' );
171 is( $stamp->days_in_month(6), 30, 'june has 30 days' );
172 is( $stamp->days_in_month(7), 31, 'july has 31 days' );
173 is( $stamp->days_in_month(8), 31, 'august has 31 days' );
174 is( $stamp->days_in_month(9), 30, 'september has 30 days' );
175 is( $stamp->days_in_month(10), 31, 'october has 31 days' );
176 is( $stamp->days_in_month(11), 30, 'november has 30 days' );
177 is( $stamp->days_in_month(12), 31, 'december has 31 days' );
184 $stamp= Timestamp->new();
185 $stamp->adjust( second => -1 );
186 is( $stamp->compare(time()), -1, 'compare earlier than now' );
187 $stamp->adjust( minute => 1 );
188 is( $stamp->compare(time()), 1, 'compare later than now' );
190 $stamp = Timestamp->new();
191 my $compare = Timestamp->new($stamp);
193 is( $stamp->compare($compare), 0, 'compare the same' );
195 $stamp->adjust( $item => -1 );
196 is( $stamp->compare($compare), -1, "$stamp $item earlier $compare" );
197 $stamp->adjust( $item => 2 );
198 is( $stamp->compare($compare), 1, "$stamp $item later $compare" );
272 $stamp = Timestamp->new($now);
273 my $epoch = $stamp->epoch_time();
281 $stamp = Timestamp->new();
282 #print "NOW: $stamp\n";
283 $stamp->adjust( months => 12 );
284 #print "ONE YEAR FROM NOW: $stamp (", $stamp->longmonth(), ")\n";
291 $stamp = Timestamp->new('2005-06-07 08:09:10');
292 is( $stamp->format('%Y/%m/%d'), '2005/06/07', 'format test date' );
293 is( $stamp->format('%Hh %Mm %Ss'), '08h 09m 10s', 'format test time' );
300 my $copy = Timestamp->new($stamp);
302 is( $copy->compare($stamp), 0, 'copy same as original' );
308 isnt( refaddr($stamp), refaddr($copy), 'copy is new object' );
309 isnt( refaddr($stamp), refaddr($other), 'new is new object' );
329 is( $tstamp->date, '2009-01-10', "TS stamp date" );
330 is( $tstamp->year, 2009, "TS stamp year" );
331 is( $tstamp->minutes, 14, "TS stamp month" );