1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556
|
#
#
#
# The test cases in this file assume that the first day of week is Sunday
# and the minimal days in the first week is 1.
locale ja JP JP
new instance jcal
timezone Asia/Tokyo
new instance tokyocal
test roll HOUR_OF_DAY
use jcal
clear all
set era Heisei
set datetime 1 Jan 8 23 59 59
roll hour_of_day 1
check datetime 1 Jan 8 0 59 59
check ampm AM
check hour 0
roll hour_of_day -1
check datetime 1 Jan 8 23 59 59
roll hour_of_day 240
check datetime 1 Jan 8 23 59 59
roll hour_of_day -240
check datetime 1 Jan 8 23 59 59
test roll HOUR
use jcal
clear all
set era Showa
set datetime 64 Jan 7 11 59 59
get ampm
check era Showa
check hour 11
check ampm AM
roll hour 1
check hour 0
check ampm AM
check datetime 64 Jan 7 0 59 59
roll hour -1
check datetime 64 Jan 7 11 59 59
roll hour 240
check datetime 64 Jan 7 11 59 59
roll hour -240
check datetime 64 Jan 7 11 59 59
clear all
set era Showa
set datetime 64 Jan 7 23 59 59
get ampm
check era Showa
check hour 11
check ampm PM
roll hour 1
check hour 0
check ampm PM
check datetime 64 Jan 7 12 59 59
roll hour -1
check datetime 64 Jan 7 23 59 59
roll hour 240
check datetime 64 Jan 7 23 59 59
roll hour -240
check datetime 64 Jan 7 23 59 59
clear all
set era Heisei
set datetime 1 Jan 8 23 59 59
get ampm
check hour 11
check ampm PM
roll hour 1
check hour 0
check ampm PM
check datetime 1 Jan 8 12 59 59
roll hour -1
check datetime 1 Jan 8 23 59 59
roll hour 240
check datetime 1 Jan 8 23 59 59
roll hour -240
check datetime 1 Jan 8 23 59 59
test roll YEAR
clear all
set date BeforeMeiji 1867 Jan 1
get actualmin year
# roll to the min year value of Gregorian (not Julian)
roll year 1
check date BeforeMeiji $result Jan 1
roll year -1
check date BeforeMeiji 1867 Jan 1
clear all
set date Meiji 45 Jul 29
roll year 1
check date Meiji 1 Jul 29
roll year -1
check date Meiji 45 Jul 29
clear all
set date Meiji 44 Jul 30
roll year 1
check date Meiji 1 Jul 30
roll year -1
check date Meiji 44 Jul 30
clear all
set date Taisho 15 Aug 1
roll year 1
check date Taisho 1 Aug 1
roll year -1
check date Taisho 15 Aug 1
clear all
set date Taisho 14 Dec 31
roll year 1
check date Taisho 1 Dec 31
roll year -1
check date Taisho 14 Dec 31
clear all
set date Showa 63 Feb 1
# Neither 64 Feb 1 nor 1 Feb 1 exists in Showa.
roll year 1
check date Showa 2 Feb 1
roll year -1
check date Showa 63 Feb 1
set date Showa 63 Dec 30
roll year 1
# Showa 1 Dec 30 exists.
check date Showa 1 Dec 30
roll year -1
check date Showa 63 Dec 30
set date Showa 64 Jan 7
roll year 1
check date Showa 2 Jan 7
roll year -1
check date Showa 64 Jan 7
set date Heisei 31 Apr 30
roll year 1
check date Heisei 1 Apr 30
roll year -1
check date Heisei 31 Apr 30
set date Reiwa 2 Apr 30
get max year
assign $result $hmax
roll year -1
check date Reiwa $hmax Apr 30
roll year 1
check date Reiwa 2 Apr 30
test roll MONTH
set date BeforeMeiji 1867 Dec 1
roll month 1
check date BeforeMeiji 1867 Jan 1
roll month -1
check date BeforeMeiji 1867 Dec 1
roll month 14
check date BeforeMeiji 1867 Feb 1
roll month -14
check date BeforeMeiji 1867 Dec 1
set date Meiji 1 Dec 1
roll month 1
check date Meiji 1 Jan 1
roll month -1
check date Meiji 1 Dec 1
roll month 13
check date Meiji 1 Jan 1
roll month -13
check date Meiji 1 Dec 1
set date Meiji 45 Jun 30
roll month 1
# Meiji 45 Jun 30 is actually Taisho 1 Jun 30. By the rule of
# roll() that year can't be changed, the day of month value
# has to be changed ("pin date to month").
check date Meiji 45 Jul 29
roll month -1
# doesn't roll back to Jun 30, but to Jun 29.
check date Meiji 45 Jun 29
set date Meiji 45 Jun 30
# Meiji 45 (year) has only 7 months. rolling 14 months must
# bring the given date to the same date.
roll month 14
check date Meiji 45 Jun 30
roll month -14
check date Meiji 45 Jun 30
# Taisho Gan-nen (year 1) has only 6 months.
set date Taisho 1 Jul 30
roll month -1
check date Taisho 1 Dec 30
roll month 1
check date Taisho 1 Jul 30
roll month -18
check date Taisho 1 Jul 30
roll month 18
check date Taisho 1 Jul 30
set date Taisho 15 Jan 20
roll month 11
check date Taisho 15 Dec 20
set date Taisho 15 Jan 25
roll month 11
# Taisho 15 Dec 25 is actually Showa 1 Dec 25. Day of month is
# adjusted to the last day of month. ("pin date to month")
check date Taisho 15 Dec 24
set date Showa 1 Dec 25
roll month 1
check date Showa 1 Dec 25
roll month -1
check date Showa 1 Dec 25
roll month 17
check date Showa 1 Dec 25
roll month -17
check date Showa 1 Dec 25
set date Showa 64 Jan 7
roll month 1
check date Showa 64 Jan 7
set date Heisei 1 Feb 1
roll month -1
# Heisei starts from Jan 8.
check date Heisei 1 Jan 8
roll month 1
check date Heisei 1 Feb 8
set date Heisei 1 Feb 8
roll month -1
check date Heisei 1 Jan 8
set date Heisei 1 Dec 1
roll month 1
check date Heisei 1 Jan 8
roll month -1
check date Heisei 1 Dec 8
set date Heisei 1 Dec 8
roll month 1
check date Heisei 1 Jan 8
roll month -1
check date Heisei 1 Dec 8
# time zone dependent tests
use tokyocal
clear all
set date BeforeMeiji 1 Jan 1
get min year
assign $result $minyear
# actual min date: -292275055.05.17T01:47:04.192+0900
set date BeforeMeiji $minyear Dec 31
roll month 1
check date BeforeMeiji $minyear May 31
set date BeforeMeiji $minyear Dec 1
set timeofday 1 47 4 192
roll month 1
check date BeforeMeiji $minyear May 17
check timeofday 1 47 4 192
set date BeforeMeiji $minyear Dec 1
set timeofday 1 47 4 191
roll month 1
check date BeforeMeiji $minyear May 18
check timeofday 1 47 4 191
set date Reiwa 17 Jan 1
get max year
assign $result $max
set date Reiwa $max Jul 28
roll month 1
check date Reiwa $max Aug 17
set date Reiwa $max Jul 28
set timeofday 23 59 59 999
roll month 1
check date Reiwa $max Aug 16
check timeofday 23 59 59 999
test roll WEEK_OF_YEAR
use jcal
clear all
# 1867 Dec 23 is Monday.
set date BeforeMeiji 1867 Dec 23
roll week_of_year 1
check day_of_week Mon
check date BeforeMeiji 1867 Jan 7
roll week_of_year -1
check day_of_week Mon
check date BeforeMeiji 1867 Dec 23
roll week_of_year 26
check day_of_week Mon
check date BeforeMeiji 1867 Jul 1
roll week_of_year -26
check day_of_week Mon
check date BeforeMeiji 1867 Dec 23
# 1867 Dec 23 is Wednesday.
set date Meiji 1 Dec 23
roll week_of_year 1
check day_of_week Wed
check date Meiji 1 Jan 1
roll week_of_year -1
check day_of_week Wed
check date Meiji 1 Dec 23
roll week_of_year 26
check day_of_week Wed
check date Meiji 1 Jun 24
roll week_of_year -26
check day_of_week Wed
check date Meiji 1 Dec 23
# Meiji 45 July 22 is Monday.
set date Meiji 45 Jul 22
# the next week if the first week of Taisho 1
roll week_of_year 1
check day_of_week Mon
check date Meiji 45 Jan 1
roll week_of_year -1
check day_of_week Mon
check date Meiji 45 Jul 22
roll week_of_year 26
check day_of_week Mon
check date Meiji 45 Jun 24
# Taisho Gan-nen (year 1) July 30 is Tuesday.
set date Taisho 1 Jul 30
roll week_of_year -1
# Taisho Gen-nen December 31 is the first week of the next year.
check day_of_week Tue
check date Taisho 1 Dec 24
roll week_of_year 1
check day_of_week Tue
check date Taisho 1 Jul 30
roll week_of_year 26
check day_of_week Tue
check date Taisho 1 Aug 27
roll week_of_year -26
check day_of_week Tue
check date Taisho 1 Jul 30
# Taisho 15 January 7 is Thursday.
set date Taisho 15 Jan 7
roll week_of_year -1
check day_of_week Thu
check date Taisho 15 Dec 16
roll week_of_year 1
check day_of_week Thu
check date Taisho 15 Jan 7
roll week_of_year 51
check day_of_week Thu
check date Taisho 15 Jan 14
# Showa Gan-nen December 30 is Thursday. Showa Gan-nen has
# only one week. Rolling any number of weeks brings to the
# same date.
set date Showa 1 Dec 30
roll week_of_year 1
check day_of_week Thu
check date Showa 1 Dec 30
roll week_of_year -1
check day_of_week Thu
check date Showa 1 Dec 30
roll week_of_year 26
check day_of_week Thu
check date Showa 1 Dec 30
roll week_of_year -26
check day_of_week Thu
check date Showa 1 Dec 30
# Showa 64 January 7 is Saturday. The year has only one week.
set date Showa 64 Jan 7
roll week_of_year 1
check day_of_week Sat
check date Showa 64 Jan 7
roll week_of_year -1
check day_of_week Sat
check date Showa 64 Jan 7
roll week_of_year 26
check day_of_week Sat
check date Showa 64 Jan 7
roll week_of_year -26
check day_of_week Sat
check date Showa 64 Jan 7
# Heisei Gan-nen January 14 is Saturday.
set date Heisei 1 Jan 14
roll week_of_year -1
check day_of_week Sat
check date Heisei 1 Dec 30
roll week_of_year 1
check day_of_week Sat
check date Heisei 1 Jan 14
roll week_of_year -26
check day_of_week Sat
check date Heisei 1 Jul 8
roll week_of_year 26
check day_of_week Sat
check date Heisei 1 Jan 14
# Heisei Gan-nen December 1 is Friday.
set date Heisei 1 Dec 1
roll week_of_year 5
check day_of_week Fri
check date Heisei 1 Jan 13
roll week_of_year -5
check day_of_week Fri
check date Heisei 1 Dec 1
roll week_of_year 55
check day_of_week Fri
check date Heisei 1 Dec 29
use tokyocal
clear all
set date BeforeMeiji $minyear Dec 25
check day_of_week Sat
roll week_of_year 1
check day_of_week Sat
check date BeforeMeiji $minyear May 22
roll week_of_year -1
check day_of_week Sat
check date BeforeMeiji $minyear Dec 25
test WEEK_OF_MONTH
# Needs to wait for 6191841 fix. (WEEK_OF_MONTH needs to change
# ERA and YEAR in a transition month.)
test DAY_OF_MONTH
# Needs to wait for 6191841 fix. (DAY_OF_MONTH needs to change
# ERA and YEAR in a transition month.)
test DAY_OF_YEAR
use jcal
clear all
# 1867 is a regular Gregorian year.
set date BeforeMeiji 1867 Dec 31
roll day_of_year 1
check date BeforeMeiji 1867 Jan 1
roll day_of_year -1
check date BeforeMeiji 1867 Dec 31
roll day_of_year 26
check date BeforeMeiji 1867 Jan 26
roll day_of_year -26
check date BeforeMeiji 1867 Dec 31
# Meiji 1 starts from Jan 1. It's a regular year as well.
set date Meiji 1 Dec 31
roll day_of_year 1
check date Meiji 1 Jan 1
roll day_of_year -1
check date Meiji 1 Dec 31
roll day_of_year 26
check date Meiji 1 Jan 26
roll day_of_year -26
check date Meiji 1 Dec 31
# The last year of Meiji (45) has an irregularity. Meiji 45
# July 30 is actually Taisho 1 July 30.
set date Meiji 45 Jul 29
roll day_of_year 1
check date Meiji 45 Jan 1
roll day_of_year -1
check date Meiji 45 Jul 29
roll day_of_year 26
check date Meiji 45 Jan 26
roll day_of_year -26
check date Meiji 45 Jul 29
# The first day of Taisho, July 30.
set date Taisho 1 Jul 30
roll day_of_year -1
check date Taisho 1 Dec 31
roll day_of_year 1
check date Taisho 1 Jul 30
roll day_of_year 26
check date Taisho 1 Aug 25
roll day_of_year -26
check date Taisho 1 Jul 30
set date Taisho 15 Jan 1
roll day_of_year -1
check date Taisho 15 Dec 24
roll day_of_year 1
check date Taisho 15 Jan 1
set date Showa 1 Dec 31
roll day_of_year 1
check date Showa 1 Dec 25
roll day_of_year -1
check date Showa 1 Dec 31
roll day_of_year 26
# 26 % 7 = 5
check date Showa 1 Dec 29
roll day_of_year -26
check date Showa 1 Dec 31
set date Showa 64 Jan 7
roll day_of_year 1
check date Showa 64 Jan 1
roll day_of_year -1
check date Showa 64 Jan 7
roll day_of_year 26
# 26 % 7 = 5
check date Showa 64 Jan 5
roll day_of_year -26
check date Showa 64 Jan 7
set date Heisei 1 Jan 8
roll day_of_year -1
check date Heisei 1 Dec 31
roll day_of_year 1
check date Heisei 1 Jan 8
roll day_of_year -26
check date Heisei 1 Dec 6
roll day_of_year 26
check date Heisei 1 Jan 8
set date Heisei 1 Dec 31
roll day_of_year 5
check date Heisei 1 Jan 12
roll day_of_year -5
check date Heisei 1 Dec 31
roll day_of_year 55
check date Heisei 1 Mar 3
roll day_of_year -55
check date Heisei 1 Dec 31
use tokyocal
clear all
set date BeforeMeiji $minyear Dec 31
set timeofday 1 47 4 192
roll day_of_year 1
check date BeforeMeiji $minyear May 17
check timeofday 1 47 4 192
roll day_of_year -1
check date BeforeMeiji $minyear Dec 31
check timeofday 1 47 4 192
test DAY_OF_WEEK_IN_MONTH
use jcal
clear all
|