OLD | NEW |
1 /*********************************************************************** | 1 /*********************************************************************** |
2 * COPYRIGHT: | 2 * COPYRIGHT: |
3 * Copyright (c) 1997-2014, International Business Machines Corporation | 3 * Copyright (c) 1997-2015, International Business Machines Corporation |
4 * and others. All Rights Reserved. | 4 * and others. All Rights Reserved. |
5 ***********************************************************************/ | 5 ***********************************************************************/ |
6 | 6 |
7 #include "unicode/utypes.h" | 7 #include "unicode/utypes.h" |
8 | 8 |
9 #if !UCONFIG_NO_FORMATTING | 9 #if !UCONFIG_NO_FORMATTING |
10 | 10 |
11 #include "unicode/datefmt.h" | 11 #include "unicode/datefmt.h" |
12 #include "unicode/smpdtfmt.h" | 12 #include "unicode/smpdtfmt.h" |
13 #include "unicode/gregocal.h" | 13 #include "unicode/gregocal.h" |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 || getField(d[0], UCAL_MONTH) == UCAL_OCTOBER)) | 429 || getField(d[0], UCAL_MONTH) == UCAL_OCTOBER)) |
430 || !hasZoneDisplayName) | 430 || !hasZoneDisplayName) |
431 ) | 431 ) |
432 { | 432 { |
433 maxSmatch = 2; | 433 maxSmatch = 2; |
434 } | 434 } |
435 // If zone display name is used, fallback format might be used b
efore 1970 | 435 // If zone display name is used, fallback format might be used b
efore 1970 |
436 else if (hasZoneDisplayName && d[0] < 0) { | 436 else if (hasZoneDisplayName && d[0] < 0) { |
437 maxSmatch = 2; | 437 maxSmatch = 2; |
438 } | 438 } |
| 439 else if (timeOnly && !isGregorian && hasZoneDisplayName && maxSm
atch == 1) { |
| 440 int32_t startRaw, startDst; |
| 441 fmt->getTimeZone().getOffset(d[1], FALSE, startRaw, startDst
, status); |
| 442 failure(status, "TimeZone::getOffset"); |
| 443 // If the calendar type is not Gregorian and the pattern is
time only, |
| 444 // the calendar implementation may use a date before 1970 as
day 0. |
| 445 // In this case, time zone offset of the default year might
be |
| 446 // different from the one at 1970-01-01 in PST and string ma
tch requires |
| 447 // one more iteration. |
| 448 if (startRaw + startDst != -28800000) { |
| 449 maxSmatch = 2; |
| 450 } |
| 451 } |
439 } | 452 } |
440 | 453 |
441 /* | 454 /* |
442 * Special case for Japanese and Buddhist (could have large negative
years) | 455 * Special case for Japanese and Buddhist (could have large negative
years) |
443 * Also, Hebrew calendar need help handling leap month. | 456 * Also, Hebrew calendar need help handling leap month. |
444 */ | 457 */ |
445 if(dmatch > maxDmatch || smatch > maxSmatch) { | 458 if(dmatch > maxDmatch || smatch > maxSmatch) { |
446 const char *type = fmt->getCalendar()->getType(); | 459 const char *type = fmt->getCalendar()->getType(); |
447 if(!strcmp(type,"japanese") || (!strcmp(type,"buddhist"))) { | 460 if(!strcmp(type,"japanese") || (!strcmp(type,"buddhist"))) { |
448 maxSmatch = 4; | 461 maxSmatch = 4; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 // Now scale up to ms | 587 // Now scale up to ms |
575 a *= 365.25 * 24 * 60 * 60 * 1000; | 588 a *= 365.25 * 24 * 60 * 60 * 1000; |
576 | 589 |
577 //return new Date((long)a); | 590 //return new Date((long)a); |
578 return a; | 591 return a; |
579 } | 592 } |
580 | 593 |
581 #endif /* #if !UCONFIG_NO_FORMATTING */ | 594 #endif /* #if !UCONFIG_NO_FORMATTING */ |
582 | 595 |
583 //eof | 596 //eof |
OLD | NEW |