Skip to content
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

Provide use localtime option on FileTime handling #41

Open
cosmo0920 opened this issue Oct 16, 2021 · 0 comments
Open

Provide use localtime option on FileTime handling #41

cosmo0920 opened this issue Oct 16, 2021 · 0 comments

Comments

@cosmo0920
Copy link
Member

Currently, we're assuming UTC implicitly on FileTime handling:

if (EvtVarTypeNull != pRenderedValues[EvtSystemTimeCreated].Type) {
ullTimeStamp = pRenderedValues[EvtSystemTimeCreated].FileTimeVal;
ft.dwHighDateTime = (DWORD)((ullTimeStamp >> 32) & 0xFFFFFFFF);
ft.dwLowDateTime = (DWORD)(ullTimeStamp & 0xFFFFFFFF);
FileTimeToSystemTime(&ft, &st);
ullNanoseconds =
(ullTimeStamp % 10000000) *
100; // Display nanoseconds instead of milliseconds for higher resolution
_snprintf_s(buffer,
_countof(buffer),
_TRUNCATE,
"%02d/%02d/%02d %02d:%02d:%02d.%llu",
st.wYear,
st.wMonth,
st.wDay,
st.wHour,
st.wMinute,
st.wSecond,
ullNanoseconds);
rb_hash_aset(hash,
rb_str_new2("TimeCreated"),
rb_str_new2(buffer));
} else {
rb_hash_aset(hash,
rb_str_new2("TimeCreated"),
Qnil);
}

This is because FileTimeToSystemTime just handles FileTime as UTC.
If we want to convert this UTC based FileTime, we have to call FileTimeToLocalFileTime before calling FileTimeToSystemTime API.
This default behavior is reasonable for western countries. But, for Asia-Pacific countries, its quite weird impressions for some users.

@cosmo0920 cosmo0920 changed the title Provide use localtime option on FileTime handling Provide use localtime option on FileTime handling Oct 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant