-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Timezone location is ignored when formatting time.Time to Excel date. #1069
Comments
Thanks for your issue, I have fixed it, please upgrade to the master branch code, and this patch will be released in the next version. |
The change is in commit 7907650. |
Unfortunately the change is, like the suggested workaround in the description of this issue, just incorrect because it assumes that the time zone offset is fixed. But this is not the case over time: time offset change in history, but also much more often in timezone that use daylight saving. So the only safe timezone to use with excelize is still |
Can you elaborate further why this doesn't work, or perhaps demonstrate an edge case? |
Description
Using the StreamWriter (possibly with non-streaming API as well but haven't tested as much), outputting a cell with a time.Time value that has its
loc
field defined with a valid time.Location does not result in a timezone-accurate float value being written to Excel.If the original time value was parsed from a UTC timestamp string, and it had its location specified by using
.In(timezone)
to set theloc
field, it seems this is ignored by excelize's conversion to an excel float value (ie: it never applies the timezone offset).A workaround for this for the time being:
Steps to reproduce the issue:
time.Time
value and set its location:Cell{}
and set it'sValue
field with the time value..SetRow()
Describe the results you received:
Cell in spreadsheet software shows the time as UTC instead of specified timezone.
Describe the results you expected:
Cell in spreadsheet software shows the correct time for the timezone specified.
Output of
go version
:Excelize version or commit ID:
Environment details (OS, Microsoft Excel™ version, physical, etc.):
MacOS Big Sur
The text was updated successfully, but these errors were encountered: