Skip to content

strptime: Support some of abbriviated timezone strings for GNU extensions #10379

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

Merged
merged 9 commits into from
May 23, 2025

Conversation

cosmo0920
Copy link
Contributor

@cosmo0920 cosmo0920 commented May 22, 2025

I implemented a capability to process TimeZone strings.
Plus, FLB_HAVE_ZONE is currently nothing effective. This is a vestigial macro that was used or copied from the original BSD's strptime.c code.
Instead, we're able to use a detector which tries to compile the tm_zone member existence in struct tm to enable the conditional macro for tm_zone.
Also, I added basic scenarios to run assertions for time zone strings and other functionalities on flb_strptime.

The corresponding issue is: #10331

This is because internally, we use flb_strptime as a time format parser on flb_parser.c.
So, this change is effective for fluent-bit's parser.


The current supported time zone labels of 3-4 letter abbreviated strings:

Supported Timezone Abbreviations

UTC/GMT and Zulu

Abbreviation UTC Offset (HH:MM) Offset (Seconds) Is DST Description
GMT +00:00 0 0 Greenwich Mean Time
UTC +00:00 0 0 Coordinated Universal Time
Z +00:00 0 0 Zulu Time (UTC)
UT +00:00 0 0 Universal Time

North American Timezones

Abbreviation UTC Offset (HH:MM) Offset (Seconds) Is DST Description
EST -05:00 -18000 0 Eastern Standard Time
EDT -04:00 -14400 1 Eastern Daylight Time
CST -06:00 -21600 0 Central Standard Time (North America)
CDT -05:00 -18000 1 Central Daylight Time (North America)
MST -07:00 -25200 0 Mountain Standard Time
MDT -06:00 -21600 1 Mountain Daylight Time
PST -08:00 -28800 0 Pacific Standard Time
PDT -07:00 -25200 1 Pacific Daylight Time
AKST -09:00 -32400 0 Alaska Standard Time
AKDT -08:00 -28800 1 Alaska Daylight Time
HST -10:00 -36000 0 Hawaii Standard Time
HADT -09:00 -32400 1 Hawaii-Aleutian Daylight Time (rarely used for Hawaii)
AST -04:00 -14400 0 Atlantic Standard Time (e.g., Canada, Caribbean)
ADT -03:00 -10800 1 Atlantic Daylight Time
NST -03:30 -12600 0 Newfoundland Standard Time
NDT -02:30 -9000 1 Newfoundland Daylight Time

European Timezones

Abbreviation UTC Offset (HH:MM) Offset (Seconds) Is DST Description
WET +00:00 0 0 Western European Time
WEST +01:00 3600 1 Western European Summer Time
CET +01:00 3600 0 Central European Time
CEST +02:00 7200 1 Central European Summer Time
EET +02:00 7200 0 Eastern European Time
EEST +03:00 10800 1 Eastern European Summer Time
MSK +03:00 10800 0 Moscow Standard Time

South American Timezones

Abbreviation UTC Offset (HH:MM) Offset (Seconds) Is DST Description
ART -03:00 -10800 0 Argentina Time
BRT -03:00 -10800 0 Brazil Time (main population areas, can vary by region/DST)
BRST -02:00 -7200 1 Brazil Summer Time (historical, not currently observed by all)
CLT -04:00 -14400 0 Chile Standard Time
CLST -03:00 -10800 1 Chile Summer Time

Australasian / Oceanian Timezones

Abbreviation UTC Offset (HH:MM) Offset (Seconds) Is DST Description
AEST +10:00 36000 0 Australian Eastern Standard Time
AEDT +11:00 39600 1 Australian Eastern Daylight Time
ACST +09:30 34200 0 Australian Central Standard Time
ACDT +10:30 37800 1 Australian Central Daylight Time
AWST +08:00 28800 0 Australian Western Standard Time
NZST +12:00 43200 0 New Zealand Standard Time
NZDT +13:00 46800 1 New Zealand Daylight Time

Asian Timezones

Abbreviation UTC Offset (HH:MM) Offset (Seconds) Is DST Description
JST +09:00 32400 0 Japan Standard Time
KST +09:00 32400 0 Korea Standard Time
SGT +08:00 28800 0 Singapore Time
IST +05:30 19800 0 India Standard Time
GST +04:00 14400 0 Gulf Standard Time (e.g., UAE, Oman)
ICT +07:00 25200 0 Indochina Time (Thailand, Vietnam, Laos, Cambodia)
WIB +07:00 25200 0 Western Indonesian Time
WITA +08:00 28800 0 Central Indonesian Time
WIT +09:00 32400 0 Eastern Indonesian Time
MYT +08:00 28800 0 Malaysia Time
BDT +06:00 21600 0 Bangladesh Standard Time
NPT +05:45 20700 0 Nepal Time

African Timezones

Abbreviation UTC Offset (HH:MM) Offset (Seconds) Is DST Description
WAT +01:00 3600 0 West Africa Time
CAT +02:00 7200 0 Central Africa Time
EAT +03:00 10800 0 East Africa Time
SAST +02:00 7200 0 South Africa Standard Time

Military Timezones

These are single-letter UTC offset designators. 'J' (Juliett) represents local time and is not included. 'Z' (Zulu) is UTC and listed above.

Abbreviation UTC Offset (HH:MM) Offset (Seconds) Is DST Description
A +01:00 3600 0 Alpha Time Zone
B +02:00 7200 0 Bravo Time Zone
C +03:00 10800 0 Charlie Time Zone
D +04:00 14400 0 Delta Time Zone
E +05:00 18000 0 Echo Time Zone
F +06:00 21600 0 Foxtrot Time Zone
G +07:00 25200 0 Golf Time Zone
H +08:00 28800 0 Hotel Time Zone
I +09:00 32400 0 India Time Zone (Military, not India Standard Time)
K +10:00 36000 0 Kilo Time Zone
L +11:00 39600 0 Lima Time Zone
M +12:00 43200 0 Mike Time Zone
N -01:00 -3600 0 November Time Zone
O -02:00 -7200 0 Oscar Time Zone
P -03:00 -10800 0 Papa Time Zone
Q -04:00 -14400 0 Quebec Time Zone
R -05:00 -18000 0 Romeo Time Zone
S -06:00 -21600 0 Sierra Time Zone
T -07:00 -25200 0 Tango Time Zone
U -08:00 -28800 0 Uniform Time Zone
V -09:00 -32400 0 Victor Time Zone
W -10:00 -36000 0 Whiskey Time Zone
X -11:00 -43200 0 X-ray Time Zone
Y -12:00 -46800 0 Yankee Time Zone

Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • Run local packaging test showing all targets (including any new ones) build.
  • Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • Documentation required for this feature

fluent/fluent-bit-docs#1687

Backporting

  • Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

@cosmo0920 cosmo0920 force-pushed the cosmo0920-support-timezone-strings branch from fc67af9 to 3eb1fb8 Compare May 22, 2025 09:58
@cosmo0920 cosmo0920 force-pushed the cosmo0920-support-timezone-strings branch from 3eb1fb8 to e6a6197 Compare May 23, 2025 01:25
@cosmo0920 cosmo0920 force-pushed the cosmo0920-support-timezone-strings branch from e6a6197 to 0e49083 Compare May 23, 2025 02:26
@cosmo0920 cosmo0920 changed the title strptime: Support timezone strings strptime: Support some of abbriviated timezone strings May 23, 2025
@edsiper edsiper merged commit 09cec8b into master May 23, 2025
70 of 73 checks passed
@edsiper edsiper deleted the cosmo0920-support-timezone-strings branch May 23, 2025 14:49
@cosmo0920 cosmo0920 added this to the Fluent bit v4.0.3 milestone May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants