1 # 2 # 3 # 4 5 locale ja JP JP 6 new instance jcal 7 new gregorian gcal 8 9 # Use GMT+09:00 for max day of year test which depends on time zone 10 # offsets. 11 12 timezone GMT+09:00 13 new instance tokyocal 14 15 test Make sure that the maximum year value doesn't depent on era 16 use jcal 17 # Note: the max year value is as of NewEra 18 assign 292276976 $max 19 clear all 20 set date NewEra 1 May 1 21 get millis 22 check max year $max 23 assign $max $maxyear 24 25 clear all 26 set date Heisei 20 May 5 27 get millis 28 check max year $maxyear 29 30 clear all 31 set date Showa 35 May 5 32 get millis 33 check max year $maxyear 34 35 clear all 36 set date BeforeMeiji 1 Jun 1 37 get millis 38 check max year $max 39 40 test Max of ERA 41 use jcal 42 # Assumption: NewEra is the current era 43 check maximum era NewEra 44 check leastmax era NewEra 45 46 test Actual max MONTH 47 use jcal 48 clear all 49 set date BeforeMeiji 1867 Jan 31 50 check actualmax month Dec 51 # Make sure that the same value is returned after 52 # normalization. 53 get millis 54 check actualmax month Dec 55 56 clear all 57 set date Meiji 45 Mar 31 58 check actualmax month Jul 59 get millis 60 check actualmax month Jul 61 62 clear all 63 set date Taisho 15 June 1 64 check actualmax month Dec 65 get millis 66 check actualmax month Dec 67 68 clear all 69 set date Showa 64 Jan 4 70 check actualmax month Jan 71 get millis 72 check actualmax month Jan 73 74 clear all 75 set date Heisei 31 Jan 4 76 check actualmax month Apr 77 get millis 78 check actualmax month Apr 79 80 clear all 81 set date NewEra 2 Jan 1 82 set year $maxyear 83 check actualmax month Aug 84 get millis 85 check actualmax month Aug 86 87 clear all 88 set date 17 Mar 1 89 check actualmax month Dec 90 get millis 91 check actualmax month Dec 92 93 test Actual max DAY_OF_YEAR 94 use jcal 95 clear all 96 set date Meiji 1 Dec 31 97 # Meiji Gan-nen is a leap year. 98 check actualmax day_of_year 366 99 check day_of_year 366 100 101 clear all 102 set date Meiji 45 Jan 1 103 # Meiji 45 or Taishi Gan-nen is also a leap year. 104 check actualmax day_of_year 211 # 31+29+31+30+31+30+29 105 set date Meiji 45 Jul 29 106 check day_of_year 211 107 set date Taisho 1 Jul 31 108 get millis 109 check actualmax day_of_year 155 # 366 - 211 110 set date Taisho 1 Dec 31 111 check day_of_year 155 112 113 clear all 114 set date Taisho 15 Sep 23 115 check actualmax day_of_year 358 # 365 - 7 116 set date Taisho 15 Dec 24 117 check day_of_year 358 118 set date Showa 1 Dec 25 119 check actualmax day_of_year 7 120 set date Showa 1 Dec 31 121 check day_of_year 7 122 123 clear all 124 set date Showa 64 Jan 3 125 check actualmax day_of_year 7 126 set date Showa 64 Jan 7 127 check day_of_year 7 128 set date Heisei 1 Aug 9 129 check actualmax day_of_year 358 # 365 - 7 130 set date Heisei 1 Dec 31 131 check day_of_year 358 132 133 # time zone dependent 134 use tokyocal 135 clear all 136 set date NewEra $maxyear Jan 1 137 # the last date of NewEra is N292276976.08.17T16:12:55.807+0900 138 check actualmax day_of_year 229 # 31+28+31+30+31+30+31+17 139 140 test Actual max WEEK_OF_YEAR 141 use jcal 142 clear all 143 set date Meiji 1 Jan 1 144 # Meiji gan-nen is a leap year. 145 check actualmax week_of_year 52 146 147 clear all 148 set date Meiji 45 Jan 1 149 check actualmax week_of_year 30 150 set date Taisho 1 July 31 151 check actualmax week_of_year 22 152 153 clear all 154 set date Taisho 15 Sep 23 155 check actualmax week_of_year 51 156 set date Showa 1 Dec 25 157 check actualmax week_of_year 1 158 159 clear all 160 set date Showa 64 Jan 3 161 check actualmax week_of_year 1 162 set date Heisei 1 Aug 9 163 check actualmax week_of_year 51 164 165 clear all 166 set date Heisei 31 Apr 28 167 check actualmax week_of_year 17 168 set date NewEra 1 Aug 9 169 check actualmax week_of_year 35 170 171 use tokyocal 172 set date NewEra $maxyear Jan 1 173 # the last date of NewEra is N292276976.08.17T16:12:55.807+0900 (Sunday) 174 # The year is equivalent to 2003 (Gregorian). 175 check actualmax week_of_year 34 176 177 test Actual max WEEK_OF_MONTH 178 use jcal 179 clear all 180 set date Meiji 45 Jul 1 181 check actualmax week_of_month 5 182 set date Taisho 1 Jul 31 183 check actualmax week_of_month 5 184 185 clear all 186 set date Taisho 15 Dec 1 187 check actualmax week_of_month 5 188 set date Showa 1 Dec 25 189 check actualmax week_of_month 5 190 191 clear all 192 set date Showa 64 Jan 1 193 check actualmax week_of_month 5 194 set date Heisei 1 Jan 8 195 check actualmax week_of_month 5 196 197 clear all 198 set date Heisei 31 Apr 30 199 check actualmax week_of_month 5 200 set date NewEra 1 May 1 201 check actualmax week_of_month 5 202 203 use tokyocal 204 set date NewEra $maxyear Jan 1 205 # the last date of NewEra is N292276976.08.17T16:12:55.807+0900 (Sunday) 206 # The year is equivalent to 2003 (Gregorian). 207 check actualmax week_of_month 4 208 209 test Actual max DAY_OF_WEEK_IN_MONTH 210 use jcal 211 clear all 212 set date Meiji 45 Jul 1 213 check actualmax week_of_month 5 214 set date Taisho 1 Jul 31 215 check actualmax week_of_month 5 216 217 clear all 218 set date Taisho 15 Dec 1 219 check actualmax week_of_month 5 220 set date Showa 1 Dec 25 221 check actualmax week_of_month 5 222 223 clear all 224 set date Showa 64 Jan 1 225 check actualmax week_of_month 5 226 set date Heisei 1 Jan 8 227 check actualmax week_of_month 5 228 229 clear all 230 set date Heisei 31 Apr 30 231 check actualmax week_of_month 5 232 set date NewEra 1 May 1 233 check actualmax week_of_month 5 234 235 use tokyocal 236 clear all 237 set date NewEra $maxyear Jan 1 238 # the last date of NewEra is N292276976.08.17T16:12:55.807+0900 (Sunday) 239 # The year is equivalent to 2003 (Gregorian). 240 check actualmax week_of_month 4 241 242 test Actual max YEAR 243 use jcal 244 clear all 245 set date BeforeMeiji 1 Jan 1 246 check actualmax year 1867 247 248 set date Meiji 1 Jan 1 249 check actualmax year 45 250 251 set date Meiji 1 Jul 30 252 check actualmax year 44 253 254 set date Taisho 1 Jul 30 255 check actualmax year 15 256 257 set date Taisho 1 Dec 25 258 check actualmax year 14 259 260 set date Showa 2 Jan 1 261 check actualmax year 64 262 263 set date Showa 1 Dec 25 264 check actualmax year 63 265 266 set date Heisei 1 Jan 7 267 check actualmax year 64 268 269 set date Heisei 1 Aug 18 270 check actualmax year 30 271 272 set date NewEra 1 Apr 30 273 check actualmax year 31 274 275 # Date/time beyond the last date in the max year. 276 set date NewEra 1 Aug 18 277 check actualmax year 292276975 278 279 test Least max YEAR 280 set date Heisei 17 Mar 1 281 # Taisho is the shortest era, 14 years. 282 # (See above actual max YEAR case.) 283 check leastmax year 14 284 285 test Acutual min YEAR 286 # Get minimum values for comparison 287 clear all 288 set era BeforeMeiji 289 get min year 290 assign $result $minyear 291 set date $minyear Dec 31 292 eval $minyear + 1 293 assign $result $minyear_plus_one 294 295 # BeforeMeiji 1 Dec 31 should exist in the minimum year which 296 # should be the same value as the getMinimum() value. 297 set date BeforeMeiji 1 Dec 31 298 check actualmin year $minyear 299 300 # Jan 1 shouldn't exist in the same year. So the actual minimum is 301 # $minyear + 1. 302 set date 1 Jan 1 303 check actualmin year $minyear_plus_one 304 305 # 1 should be returned if it's on a date of the last 306 # year which also exists in the first year of each era. 307 clear all 308 set date Meiji 45 Jan 1 309 check actualmin year 1 310 311 clear all 312 set date Taisho 14 Jul 30 313 check actualmin year 1 314 315 clear all 316 set date Showa 60 Dec 25 317 check actualmin year 1 318 319 clear all 320 set date Heisei 17 Jan 8 321 check actualmin year 1 322 323 # 2 should be returned if it's on a date of the last year which 324 # doesn't exist in the first year of each era. (Meiji is an 325 # exception.) 326 clear all 327 set date Taisho 14 Jul 29 328 check actualmin year 2 329 330 clear all 331 set date Showa 60 Dec 23 332 check actualmin year 2 333 334 clear all 335 set date Heisei 17 Jan 7 336 check actualmin year 2