Skip to content

Commit d53c2be

Browse files
committed
Fix DST adjustments
Even if `gettimeofday` returns meaningful data in `tz_dsttime`, the value is just a flag (or, according to some sources, a tri-state value: >0 - DST applies, ==0 - DST does not apply, <0 - unknown). Hitherto, the field was simply added to/subtracted from a time value in milliseconds. To use it approximately correctly, the field's value should be multiplied by "millisecs/hour". JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
1 parent 5ff3fbe commit d53c2be

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

jerry-core/ecma/builtin-objects/ecma-builtin-helpers-date.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ ecma_date_daylight_saving_ta (ecma_number_t time) /**< time value */
479479
return ecma_number_make_nan ();
480480
}
481481

482-
return tz.daylight_saving_time;
482+
return tz.daylight_saving_time * ECMA_DATE_MS_PER_HOUR;
483483
} /* ecma_date_daylight_saving_ta */
484484

485485
/**

jerry-core/jerry-port.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void jerry_port_fatal (jerry_fatal_code_t code);
8282
typedef struct
8383
{
8484
int offset; /**< minutes from west */
85-
int daylight_saving_time; /**< daylight saving time */
85+
int daylight_saving_time; /**< daylight saving time (1 - DST applies, 0 - not on DST) */
8686
} jerry_time_zone_t;
8787

8888
/**

targets/default/jerry-port-default-date.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ bool jerry_port_get_time_zone (jerry_time_zone_t *tz_p)
3535
gettimeofday (&tv, &tz);
3636

3737
tz_p->offset = tz.tz_minuteswest;
38-
tz_p->daylight_saving_time = tz.tz_dsttime;
38+
tz_p->daylight_saving_time = tz.tz_dsttime > 0 ? 1 : 0;
3939

4040
return true;
4141
} /* jerry_port_get_time_zone */

0 commit comments

Comments
 (0)