-
Notifications
You must be signed in to change notification settings - Fork 683
Revise implementation of jerry_port_get_local_time_zone_adjustment on Win32 #4589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revise implementation of jerry_port_get_local_time_zone_adjustment on Win32 #4589
Conversation
6e0245c
to
369dacf
Compare
jerry-port/default/default-date.c
Outdated
* https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime | ||
*/ | ||
static const long long UnixEpochOfDate_1601_01_02 = -11644387200000LL; /* unit: ms */ | ||
static const long long UnixEpochOfDate_30827_12_29 = 9106702560000000LL; /* unit: ms */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not LONGLONG here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not LONGLONG here?
UnixEpoch, LONGLONG are windows specific
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this is Windows-specific code path. BTW, this code (copied from below)
if (unix_ms < UnixEpochOfDate_1601_01_02)
{
unix_ms = UnixEpochOfDate_1601_01_02;
}
if (unix_ms > UnixEpochOfDate_30827_12_29)
{
unix_ms = UnixEpochOfDate_30827_12_29;
}
is working with doubles and LONGLONGs (or long longs). It might be wise to add casts explicitly as in UnixTimeMsToFileTime and FileTimeToUnixTimeMs.
jerry-port/default/default-date.c
Outdated
@@ -57,30 +69,59 @@ static double FileTimeToUnixTimeMs (FILETIME ft) | |||
* available. Otherwise, returns 0, assuming UTC time. | |||
*/ | |||
double jerry_port_get_local_time_zone_adjustment (double unix_ms, /**< ms since unix epoch */ | |||
bool is_utc) /**< is the time above in UTC? */ | |||
bool is_utc) /**< is the time above in UTC, */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary edit. Question mark was OK.
jerry-port/default/default-date.c
Outdated
static const LONGLONG TicksPerMs = 10000; /* 1 tick is 100 nanoseconds */ | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/*
instead of /**
as this is not a doxygen comment
jerry-port/default/default-date.c
Outdated
SYSTEMTIME utcSystemTime, localSystemTime; | ||
bool timeConverted = false; | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/*
instead of /**
as this is not a doxygen comment
jerry-port/default/default-date.c
Outdated
* query time zone adjustment, this date(1601-01-02) will make sure both utc/local | ||
* time succeed with Win32 API, using date(1601-01-01) may leading win32 api | ||
* failure, as after convert between local time/utc time, the time may earlier than | ||
* date 1601-01-01 in utc time, that's exceed the FILETIME representation range. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion, edited for language: If the time is earlier than the date 1601-01-02, then always using date 1601-01-02 to query time zone adjustment. This date (1601-01-02) will make sure both UTC and local time succeed with Win32 API. The date 1601-01-01 may lead to a win32 api failure, as after converting between local time and utc time, the time may be earlier than 1601-01-01 in UTC time, that exceeds the FILETIME representation range.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
jerry-port/default/default-date.c
Outdated
UnixTimeMsToFileTime (unix_ms, &fileTime); | ||
/* If time is earlier than year 1601, then always using year 1601 to query time zone adjustment */ | ||
if (fileTime.dwHighDateTime >= 0x80000000) | ||
/* Same reason as upper, do not use the latest support day */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion, edited for language: Like above, do not use the last supported day
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both upated.
c2b6aff
to
c6be129
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not really happy about long long
s, such inconsistency just itches me. The rest looks OK with me -- in general. But the details of computations should be checked by Windows-focused reviewers.
OK, then LONGLONG |
c6be129
to
a3a16c4
Compare
a3a16c4
to
56902ee
Compare
ping for review or merge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
any progress? |
4a38d6c
to
b629b5b
Compare
… Win32 Handle the limitation of Win32 date API properly. JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo [email protected]
b629b5b
to
da3d472
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, conflicts have been resolved, it was previously accepted by 2 reviewers, but it was abandoned, I don't see why it couldn't be merged. @LaszloLango please double check and merge it if it looks good to you as well.
Handle is_utc and not is_utc properly.
Handle the limitation of Win32 date API properly.
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo [email protected]