1print "1..75\n"; 2 3use Time::Object; 4 5print "ok 1\n"; 6 7my $t = gmtime(951827696); # 2001-02-29T12:34:56 8 9print "not " unless $t->sec == 56; 10print "ok 2\n"; 11 12print "not " unless $t->second == 56; 13print "ok 3\n"; 14 15print "not " unless $t->min == 34; 16print "ok 4\n"; 17 18#print "not " unless $t->minute == 34; 19print "ok 5\n"; 20 21print "not " unless $t->hour == 12; 22print "ok 6\n"; 23 24print "not " unless $t->mday == 29; 25print "ok 7\n"; 26 27print "not " unless $t->day_of_month == 29; 28print "ok 8\n"; 29 30print "not " unless $t->mon == 2; 31print "ok 9\n"; 32 33print "not " unless $t->_mon == 1; 34print "ok 10\n"; 35 36#print "not " unless $t->monname eq 'Feb'; 37print "ok 11\n"; 38 39print "not " unless $t->month eq 'Feb'; 40print "ok 12\n"; 41 42print "not " unless $t->year == 2000; 43print "ok 13\n"; 44 45print "not " unless $t->_year == 100; 46print "ok 14\n"; 47 48print "not " unless $t->wday == 3; 49print "ok 15\n"; 50 51print "not " unless $t->_wday == 2; 52print "ok 16\n"; 53 54print "not " unless $t->day_of_week == 2; 55print "ok 17\n"; 56 57print "not " unless $t->wdayname eq 'Tue'; 58print "ok 18\n"; 59 60print "not " unless $t->day eq 'Tue'; 61print "ok 19\n"; 62 63print "not " unless $t->yday == 59; 64print "ok 20\n"; 65 66print "not " unless $t->day_of_year == 59; 67print "ok 21\n"; 68 69# In GMT there should be no daylight savings ever. 70 71print "not " unless $t->isdst == 0; 72print "ok 22\n"; 73 74print "not " unless $t->daylight_savings == 0; 75print "ok 23\n"; 76 77print "not " unless $t->hms eq '12:34:56'; 78print "ok 24\n"; 79 80print "not " unless $t->time eq '12:34:56'; 81print "ok 25\n"; 82 83print "not " unless $t->ymd eq '2000-02-29'; 84print "ok 26\n"; 85 86print "not " unless $t->date eq '2000-02-29'; 87print "ok 27\n"; 88 89print "not " unless $t->mdy eq '02-29-2000'; 90print "ok 28\n"; 91 92print "not " unless $t->dmy eq '29-02-2000'; 93print "ok 29\n"; 94 95print "not " unless $t->cdate eq 'Tue Feb 29 12:34:56 2000'; 96print "ok 30\n"; 97 98print "not " unless "$t" eq 'Tue Feb 29 12:34:56 2000'; 99print "ok 31\n"; 100 101print "not " unless $t->datetime eq '2000-02-29T12:34:56'; 102print "ok 32\n"; 103 104print "not " unless $t->epoch == 951827696; 105print "ok 33\n"; 106 107# ->tzoffset? 108 109print "not " unless ($t->julian_day / 2451604.0075) - 1 < 0.001; 110print "ok 34\n"; 111 112print "not " unless ($t->mjd / 51603.5075) - 1 < 0.001; 113print "ok 35\n"; 114 115print "not " unless $t->week == 9; 116print "ok 36\n"; 117 118# strftime tests 119 120# %a, %A, %b, %B, %c are locale-dependent 121 122# %C is unportable: sometimes its like asctime(3) or date(1), 123# sometimes it's the century (and whether for 2000 the century is 124# 20 or 19, is fun, too..as far as I can read SUSv2 it should be 20.) 125 126print "not " unless $t->strftime('%d') == 29; 127print "ok 37\n"; 128 129print "not " unless $t->strftime('%D') eq '02/29/00'; # Yech! 130print "ok 38\n"; 131 132print "not " unless $t->strftime('%e') eq '29'; # should test with < 10 133print "ok 39\n"; 134 135print "not " unless $t->strftime('%H') eq '12'; # should test with < 10 136print "ok 40\n"; 137 138 # %h is locale-dependent 139 140print "not " unless $t->strftime('%I') eq '12'; # should test with < 10 141print "ok 41\n"; 142 143print "not " unless $t->strftime('%j') == 60; # why ->yday+1 ? 144print "ok 42\n"; 145 146print "not " unless $t->strftime('%M') eq '34'; # should test with < 10 147print "ok 43\n"; 148 149# %p, %P, and %r are not widely implemented, 150# and are possibly unportable (am or AM or a.m., and so on) 151 152print "not " unless $t->strftime('%R') eq '12:34'; # should test with > 12 153print "ok 44\n"; 154 155print "not " unless $t->strftime('%S') eq '56'; # should test with < 10 156print "ok 45\n"; 157 158print "not " unless $t->strftime('%T') eq '12:34:56'; # < 12 and > 12 159print "ok 46\n"; 160 161# There are bugs in the implementation of %u in many platforms. 162# (e.g. Linux seems to think, despite the man page, that %u 163# 1-based on Sunday...) 164 165print "not " unless $t->strftime('%U') eq '09'; # Sun cmp Mon 166print "ok 47\n"; 167 168print "not " unless $t->strftime('%V') eq '09'; # Sun cmp Mon 169print "ok 48\n"; 170 171print "not " unless $t->strftime('%w') == 2; 172print "ok 49\n"; 173 174print "not " unless $t->strftime('%W') eq '09'; # Sun cmp Mon 175print "ok 50\n"; 176 177# %x is locale and implementation dependent. 178 179print "not " unless $t->strftime('%y') == 0; # should test with 1999 180print "ok 51\n"; 181 182print "not " unless $t->strftime('%Y') eq '2000'; 183print "ok 52\n"; 184 185# %Z is locale and implementation dependent 186# (there is NO standard for timezone names) 187 188print "not " unless $t->date("") eq '20000229'; 189print "ok 53\n"; 190 191print "not " unless $t->ymd("") eq '20000229'; 192print "ok 54\n"; 193print "not " unless $t->mdy("/") eq '02/29/2000'; 194print "ok 55\n"; 195 196print "not " unless $t->dmy(".") eq '29.02.2000'; 197print "ok 56\n"; 198 199print "not " unless $t->date_separator() eq '-'; 200print "ok 57\n"; 201 202$t->date_separator("/"); 203 204print "not " unless $t->ymd eq '2000/02/29'; 205print "ok 58\n"; 206 207print "not " unless $t->date_separator() eq '/'; 208print "ok 59\n"; 209 210$t->date_separator("-"); 211 212print "not " unless $t->hms(".") eq '12.34.56'; 213print "ok 60\n"; 214 215print "not " unless $t->time_separator() eq ':'; 216print "ok 61\n"; 217 218$t->time_separator("."); 219 220print "not " unless $t->hms eq '12.34.56'; 221print "ok 62\n"; 222 223print "not " unless $t->time_separator() eq '.'; 224print "ok 63\n"; 225 226$t->time_separator(":"); 227 228my @fidays = qw( sunnuntai maanantai tiistai keskiviikko torstai 229 perjantai lauantai ); 230my @frdays = qw( Dimanche Lundi Merdi Mercredi Jeudi Vendredi Samedi ); 231 232print "not " unless $t->day(@fidays) eq "tiistai"; 233print "ok 64\n"; 234my @days = $t->day_list(); 235 236$t->day_list(@frdays); 237 238print "not " unless $t->day eq "Merdi"; 239print "ok 65\n"; 240 241$t->day_list(@days); 242 243print "not " unless $t->day eq "Tue"; 244print "ok 66\n"; 245 246my @months = $t->mon_list(); 247 248my @dumonths = qw(januari februari maart april mei juni 249 juli augustus september oktober november december); 250 251print "not " unless $t->month(@dumonths) eq "februari"; 252print "ok 67\n"; 253 254$t->mon_list(@dumonths); 255 256print "not " unless $t->month eq "februari"; 257print "ok 68\n"; 258 259$t->mon_list(@months); 260 261print "not " unless $t->month eq "Feb"; 262print "ok 69\n"; 263 264print "not " unless 265 $t->datetime(date => '/', T => ' ', time => '-') eq "2000/02/29 12-34-56"; 266print "ok 70\n"; 267 268print "not " unless $t->is_leap_year; # should test more with different dates 269print "ok 71\n"; 270 271print "not " unless $t->month_last_day == 29; # test more 272print "ok 72\n"; 273 274print "not " if Time::Object::_is_leap_year(1900); 275print "ok 73\n"; 276 277print "not " if Time::Object::_is_leap_year(1901); 278print "ok 74\n"; 279 280print "not " unless Time::Object::_is_leap_year(1904); 281print "ok 75\n"; 282 283 284