Skip to content

Commit

Permalink
Merge pull request #1956 from svaarala/windows-date-trivia
Browse files Browse the repository at this point in the history
Windows Date provider return value check consistency trivia
  • Loading branch information
svaarala committed Aug 7, 2018
2 parents 17d7314 + 1e071a0 commit d044500
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
3 changes: 3 additions & 0 deletions RELEASES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3396,6 +3396,9 @@ Planned
2.4.0 (XXXX-XX-XX)
------------------

* Trivial fixes and cleanups: Windows Date provider return code check
consistency (GH-1956)

3.0.0 (XXXX-XX-XX)
------------------

Expand Down
12 changes: 3 additions & 9 deletions src-input/duk_bi_date_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ DUK_INTERNAL duk_int_t duk_bi_date_get_local_tzoffset_windows(duk_double_t d) {
ULARGE_INTEGER tmp2;
ULARGE_INTEGER tmp3;
FILETIME ft1;
BOOL ret;

/* XXX: handling of timestamps outside Windows supported range.
* How does Windows deal with dates before 1600? Does windows
Expand All @@ -116,8 +115,7 @@ DUK_INTERNAL duk_int_t duk_bi_date_get_local_tzoffset_windows(duk_double_t d) {

ft1.dwLowDateTime = tmp2.LowPart;
ft1.dwHighDateTime = tmp2.HighPart;
ret = FileTimeToSystemTime((const FILETIME *) &ft1, &st2);
if (!ret) {
if (FileTimeToSystemTime((const FILETIME *) &ft1, &st2) == 0) {
DUK_D(DUK_DPRINT("FileTimeToSystemTime() failed, return tzoffset 0"));
return 0;
}
Expand All @@ -140,7 +138,6 @@ DUK_INTERNAL duk_int_t duk_bi_date_get_local_tzoffset_windows_no_dst(duk_double_
FILETIME ft2;
ULARGE_INTEGER tmp1;
ULARGE_INTEGER tmp2;
BOOL ret;

/* Do a similar computation to duk_bi_date_get_local_tzoffset_windows
* but without accounting for daylight savings time. Use this on
Expand All @@ -156,14 +153,11 @@ DUK_INTERNAL duk_int_t duk_bi_date_get_local_tzoffset_windows_no_dst(duk_double_

ft1.dwLowDateTime = tmp1.LowPart;
ft1.dwHighDateTime = tmp1.HighPart;
ret = FileTimeToLocalFileTime((const FILETIME *) &ft1, &ft2);
if (!ret) {
if (FileTimeToLocalFileTime((const FILETIME *) &ft1, &ft2) == 0) {
DUK_D(DUK_DPRINT("FileTimeToLocalFileTime() failed, return tzoffset 0"));
return 0;
}

ret = FileTimeToSystemTime((const FILETIME *) &ft2, &st2);
if (!ret) {
if (FileTimeToSystemTime((const FILETIME *) &ft2, &st2) == 0) {
DUK_D(DUK_DPRINT("FileTimeToSystemTime() failed, return tzoffset 0"));
return 0;
}
Expand Down

0 comments on commit d044500

Please sign in to comment.