Ticket #5984 (closed defect: worksforme)

SVN Diffs for #5984

 

Opened 1 year ago

Last modified 4 months ago

UCalendar returns wrong date when local time doesn't exist due to DST

Reported by: deborah Assigned to: yoshito
Priority: assess Milestone: UNSCH
Component: time_calc Version: 3.6
Keywords: Cc:
Load: Xref:
Java Version: Operating System:
Project (C/J): ICU4C Weeks: 1
Review:

Description

Set your current timezone to Santiago Chile, which "falls forward" from a timezone of -0400 to -0300 between Oct 13, 2007 11:59:59 and Oct 14, 2007 01:00:00. So the first hour of Oct 14 doesn't exist because they jump an hour forward.

10/7/07 2:57 PM Chris Kane: 2007-10-14 00:00:00 doesn't exist, so the correct result is up to interpretation when creating a date from the tuple (2007, 10, 14, 0, 0, 0). CFAbsoluteTime 214027200.0 is 2007-10-14 01:00:00 when tz is Santiago.

After some thought, I agree with the developer: (1) the times bounding the non-existant 2007-10-14 00:00:00 are 214027199.999 [2007-10-13 23:59:59.999] and 214027200.000 [2007-10-14 01:00:00.000]; in the absence of the DST transition, 2007-10-14 00:00:00 would have been 214027200.000, and the DST transition has "re-identified" that time as 1am; and (2) a result of 214027200.000/2007-10-14 01:00:00.000 produces an answer which is closer to the non-existant time in more components.

10/7/07 3:24 PM Chris Kane: The following ICU-only program demonstrates this:

#include <unicode/ucal.h> #include <unicode/ustring.h> #include <stdlib.h> #include <stdio.h>

int main() {

UErrorCode status = U_ZERO_ERROR; UChar uzone[] = {'A', 'm', 'e', 'r', 'i', 'c', 'a', '/', 'S', 'a', 'n', 't', 'i', 'a', 'g', 'o', 0}; UCalendar *cal = ucal_open(uzone, u_strlen(uzone), "en_US@calendar=gregorian", UCAL_TRADITIONAL, &status);

if (NULL == cal U_FAILURE(status)) abort();

ucal_clear(cal); ucal_set(cal, UCAL_YEAR, 2007); ucal_set(cal, UCAL_MONTH, 10 - 1); ucal_set(cal, UCAL_DAY_OF_MONTH, 14);

status = U_ZERO_ERROR; UDate udate = ucal_getMillis(cal, &status); if (U_FAILURE(status)) abort();

if (udate == 1192334400000.0) {

printf("returned udate is 2007-10-14 01:00:00\n");

} else if (udate == 1192330800000.0) {

printf("returned udate is 2007-10-13 23:00:00\n");

} else {

printf("returned udate (%f) is something else!\n", udate);

} return 0;

}

Santiago, Chile, moves into DST at midnight on 2007-10-14, and 2007-10-13 23:59:59 is followed by 2007-10-14 01:00:00. Although the result of trying to create the non-existant 2007-10-14 00:00:00 time is somewhat ambiguous, we feel that 1192334400000.0 (2007-10-14 01:00:00) would be a better result than the current 1192330800000.0 (2007-10-13 23:00:00) in ICU 3.6.

Attachments

Change History

10/10/07 10:06:57 changed by markus

  • owner changed from somebody to markus.
  • component changed from formatting to time_calc.

10/10/07 10:13:46 changed by markus

  • weeks set to 1.

07/10/08 11:38:27 changed by srl

  • owner changed from markus to yoshito.
  • priority changed from major to assess.

07/15/08 16:05:36 changed by mark

Andy and I think this one might be fixed.

07/18/08 10:30:19 changed by yoshito

  • status changed from new to closed.
  • resolution set to worksforme.

The behavior of ambiguous time was changed after 3.6. The behavior described in this ticket matches JDK. Both ICU4C/J are now working as described (as of 4.0). I tried the sample test case above with ICU 4.0 and got "returned udate is 2007-10-14 01:00:00". So I'll close this ticket as "worksforme"


Add/Change #5984 (UCalendar returns wrong date when local time doesn't exist due to DST)




Anti spam check: