Skip to content

Conversation

seisman
Copy link
Member

@seisman seisman commented Sep 21, 2025

The solar module can accept datetime with a timezone offset with a syntax like -Td+d2010-01-01T00:00:00+z08:00, but currently Figure.solar doesn't support it.

This PR adds the support for timezone.

Internally, GMT's solar module uses the C atoi function to parse the timezone after +z, so "08:00" -> 8, "-05:00"->-5, and fractional offsets are cast to integers, e.g. "08:30"->8, "-05:30"->-5.

Preview: https://pygmt-dev--4112.org.readthedocs.build/en/4112/api/generated/pygmt.Figure.solar.html

Address #4110.

@seisman seisman added this to the 0.17.0 milestone Sep 21, 2025
@seisman seisman added enhancement Improving an existing feature needs review This PR has higher priority and needs review. labels Sep 21, 2025
@GenericMappingTools GenericMappingTools deleted a comment from github-actions bot Sep 21, 2025
Copy link
Contributor

github-actions bot commented Sep 21, 2025

Summary of changed images

This is an auto-generated report of images that have changed on the DVC remote

Status Path
added pygmt/tests/baseline/test_solar_terminator_datetime_timezone.png

Image diff(s)

Added images

  • test_solar_terminator_datetime_timezone.png

Modified images

Path Old New

Report last updated at commit caba47b

@seisman seisman changed the title Figure.solar: Support datetime with timezone Figure.solar: Support terminator datetime with timezone Sep 22, 2025
Comment on lines 58 to 62
Set the date and time for the terminator calculation. It can be provided as a
string or any datetime-like object recognized by :func:`pandas.to_datetime`. The
time can be specified in UTC or using a UTC offset. The offset must be an
integer number of hours (e.g., -8 or +5); fractional hours (e.g., -8.5 or +5.5)
are cast to integer. [Default is the current UTC date and time].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can mention that it is the lower integer, e.g. 8.5 -> 8, not 9.

Suggested change
Set the date and time for the terminator calculation. It can be provided as a
string or any datetime-like object recognized by :func:`pandas.to_datetime`. The
time can be specified in UTC or using a UTC offset. The offset must be an
integer number of hours (e.g., -8 or +5); fractional hours (e.g., -8.5 or +5.5)
are cast to integer. [Default is the current UTC date and time].
Set the date and time for the terminator calculation. It can be provided as a
string or any datetime-like object recognized by :func:`pandas.to_datetime`. The
time can be specified in UTC or using a UTC offset. The offset must be an
integer number of hours (e.g., -8 or +5); fractional hours (e.g., -8.5 or +5.5)
are cast to the lower integer. [Default is the current UTC date and time].

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed it to "fractional hours (e.g., -8.5 or +5.5) are truncated towards zero (e.g., -8.5 becomes -8 and +5.5 becomes +5)."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improving an existing feature needs review This PR has higher priority and needs review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants