Skip to content

fix: unrobust time relevant tostring functions.#24

Merged
johannessen merged 2 commits intomajensen:mainfrom
npc1054657282:fix/unrobust-datetime-tostring
Aug 2, 2025
Merged

fix: unrobust time relevant tostring functions.#24
johannessen merged 2 commits intomajensen:mainfrom
npc1054657282:fix/unrobust-datetime-tostring

Conversation

@npc1054657282
Copy link
Copy Markdown
Contributor

  1. Multithread unsafe functions localtime and gmtime used in time relevant to string functions. Use them in multithread scenes will result in unpredictable consequences. Use localtime_r and gmtime_r instead.
  2. Support minute-level time zone offsets print. Some coutries' time needs this , e.g. India (+0530).

`localtime` and `gmtime` are multithread unsafe functions.
Use them in multithread scenes will result in unpredictable consequences.
Use `localtime_r` and `gmtime_r` instead.
The previous implementation for formatting timezone offsets incorrectly
assumed all offsets are full hours. It calculated the hour component
via integer division (`offset / 3600`) and hardcoded "00" for the
minutes.
This resulted in incorrect timestamps for timezones with 30 or 45-minute
offsets, such as India Standard Time (IST, +05:30) being formatted
as "+0500" instead of the correct "+0530".
@npc1054657282 npc1054657282 force-pushed the fix/unrobust-datetime-tostring branch from 8a37235 to d230ddd Compare June 28, 2025 06:57
@johannessen johannessen merged commit e3f4ed9 into majensen:main Aug 2, 2025
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants