Skip to content

solar: Fix +z time zone offsets truncated to whole hours - #9221

Merged
Esteban82 merged 5 commits into
masterfrom
fix-9220-pssolar-tz-offset
Sep 23, 2026
Merged

Esteban82 merged 5 commits into
masterfrom
fix-9220-pssolar-tz-offset

Conversation

@Esteban82

@Esteban82 Esteban82 commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Description of proposed changes

solar ignored the minutes of the +z time zone offset: +z08:30 gave the same result as +z08:00. The offset was read with atoi, which stops at the :.

The offset is now parsed with gmt_scanf_arg (GMT_IS_GEO), so [-]hh[:mm] works for both -I and -T (e.g. +z05:45, +z-03:30). A malformed value such as +zabc now gives a parse error instead of silently falling back to UTC.

It also works for time zones that include seconds, which isn't particularly useful, but that's just how it was implemented. The docs only describe [-]hh[:mm].

Fixes #9220

Reproduction

gmt begin BUG_TZoffset png
	gmt basemap -JH14c -Baf -Rg
	gmt solar -Td+d2020-01-01T00:00:00+z08:00 -W1p,black
	gmt solar -Td+d2020-01-01T00:00:00+z08:30 -W1p,yellow,-
	gmt solar -Td+d2020-01-01T00:00:00+z09:00 -W1p,red
gmt end show
BUG_TZoffset

🤖 Generated with Claude Code. Review with Opus 5.5.

Esteban82 and others added 3 commits September 23, 2026 08:19
pssolar_parse_date_tz() used atoi() on the +z<TZ> suffix, which stops
at the first non-numeric character, so +z08:30 and +z08:00 both parsed
to 8. Change TZ from int to double throughout (PSSOLAR_I, PSSOLAR_T,
the parser signature, and locals in parse()/pssolar_params()) and
replace atoi with a [-]hh[:mm] parser.

Fixes #9220

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Extend the [-]hh[:mm] timezone parser to [-]hh[:mm[:ss]] so a second
colon-separated field (e.g. +z08:30:15) is added as sec/3600 instead
of being silently dropped.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Replace the hand-rolled [-]hh[:mm[:ss]] parser with gmt_scanf_arg
(GMT_IS_GEO), which already handles that format including the -00:30
sign case, and report a parse error for malformed time zones instead
of silently using a wrong offset. Document the accepted format (and
use ASCII minus signs in the examples so they can be copy-pasted), and
add a self-checking test that recovers the offset from the -C output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Esteban82 Esteban82 added the add-changelog Add PR to the changelog label Sep 23, 2026
Seconds are still accepted by the parser, but they are not useful for
real time zones, so leave them out of the docs, usage and error message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Esteban82
Esteban82 marked this pull request as ready for review September 23, 2026 12:28
@Esteban82
Esteban82 merged commit c240608 into master Sep 23, 2026
14 of 18 checks passed
@Esteban82
Esteban82 deleted the fix-9220-pssolar-tz-offset branch September 23, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

add-changelog Add PR to the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

solar: Fractional timezone offsets are cast to integers

2 participants