Skip to content

solar/pssolar: Reject -T arguments that aren't d/c/n/a letters - #9222

Merged
Esteban82 merged 1 commit into
masterfrom
fix-pssolar-missing-plusd-date
Sep 23, 2026
Merged

Esteban82 merged 1 commit into
masterfrom
fix-pssolar-missing-plusd-date

Conversation

@Esteban82

@Esteban82 Esteban82 commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Description of proposed changes

-T's date must be given with the +d prefix: -Tdcna[+d<date>][+z<TZ>]. If +d is forgotten and a date is glued directly after the type letters (e.g. -Td2020-01-01T00:00:00 instead of -Td+d2020-01-01T00:00:00), GMT doesn't error - it silently ignores the leftover text and plots today's date instead of the one requested.

Found while investigating gh#9220: that issue's own reproduction script has this exact typo, so it never actually pinned the date to 2020-01-01 (it always plotted "now" - the TZ-offset comparison in that issue is still valid regardless, since it doesn't depend on which day it runs). This same mistake is easy to make since, unlike -I, the d right after -T is the terminator-type selector, not the start of the date.

This PR makes -T reject any character in its argument that isn't d, c, n, or a, so this typo now produces a clear parse error instead of silently plotting the wrong day.

Reproduction

gmt begin BUG_MissingPlusD png
	gmt basemap -JH14c -Baf -Rg
	gmt solar -Td2020-12-21T12:00:00 -W2p,blue
	gmt solar -Td2020-06-21T12:00:00 -W1p,red,-
gmt end

December 21 and June 21 are six months apart (opposite solstices) and should produce near-mirrored terminators, but both silently plot "now" instead, so the two lines land exactly on top of each other (screenshot attached separately to the requester).

Reminders

  • Make sure that your code follows our style. Use the other functions/files as a basis.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Describe changes to function behavior and arguments in a comment below the function declaration.
  • If adding new functionality, add a detailed description to the documentation and/or an example.

🤖 Generated with Claude Code

-T's date must be given as +d<date> (-Tdcna[+d<date>][+z<TZ>]). If the
+d is forgotten and a date is glued directly after the type letters
(e.g. -Td2020-01-01T00:00:00, instead of -Td+d2020-01-01T00:00:00),
the leftover text was silently scanned for d/c/n/a and otherwise
ignored: no error, and pssolar_params() falls back to using today's
real date instead of the one the user typed, since Ctrl->T.calendar
was never populated.

Found while investigating gh#9220: that issue's own reproduction
script has this exact typo, so it (and this session's own test
scripts) never actually plotted 2020-01-01 - only "now". This didn't
invalidate the TZ-offset comparison itself (still a fair comparison
at whatever instant the command ran), but it means -T's +d has likely
never worked as documented for anyone who made the same easy mistake.

Add a self-checking test that fails on the old (missing-+d) behavior
and confirms +d is honored (Jan vs June terminators differ).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Esteban82
Esteban82 marked this pull request as ready for review September 23, 2026 13:11
@Esteban82
Esteban82 merged commit 8e7bc7e into master Sep 23, 2026
15 of 20 checks passed
@Esteban82
Esteban82 deleted the fix-pssolar-missing-plusd-date branch September 23, 2026 13:13
@Esteban82 Esteban82 added the add-changelog Add PR to the changelog label Sep 23, 2026
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.

2 participants