Skip to content

Sunset times are off for Australia #172

Closed

Description

@mhollanders

Hi there,

The follow code gives me the wrong sunrise and sunset times for eastern Australia; Google tells me sunset is at 17:38 AEST (UTC+10).

getSunlightTimes(date = ymd("2023-09-15"),
                 lat = 28.865, lon = 153.565,
                 tz = "Etc/GMT+10",
                 keep = c("sunrise", "sunset"))
    date    lat     lon             sunrise              sunset

1 2023-09-15 28.865 153.565 2023-09-14 09:31:32 2023-09-14 21:53:54

Any idea what's going on?

Matt

Activity

  1. virtualgeoff commented on Sep 16, 2023

    @virtualgeoff

    Australia is in the Southern Hemisphere; latitude should be negative!

  2. mhollanders commented on Sep 17, 2023

    @mhollanders
    Author

    Hi, you're correct. -28.865, 153.565 still gives the wrong results.

        date     lat     lon             sunrise              sunset
    

    1 2023-09-15 -28.865 153.565 2023-09-14 09:46:16 2023-09-14 21:39:09

  3. sepsep361 commented on Nov 13, 2023

    @sepsep361

    I've got the same problem as you. Change time zone of your computer.

  4. mourner commented on Jun 18, 2026

    @mourner
    Owner

    Two separate issues here, and neither is actually a bug in the calculation:

    1. Latitude sign — Australia is southern hemisphere, so -28.865 (already caught by @virtualgeoff). ✓
    2. Timezone string — Etc/GMT+10 is a POSIX gotcha: the sign is inverted, so it means UTC−10, not AEST. AEST (UTC+10) is Etc/GMT-10, or better just Australia/Brisbane. The 20-hour error from this is what landed sunset on the wrong day.

    With both corrected, the math is spot on. Verified against the underlying SunCalc v2:

    getTimes(2023-09-15, -28.865, 153.565)
      sunset UTC 2023-09-15T07:38:06Z → 17:38 AEST  ✓ (matches Google)
    

    SunCalc works entirely in UTC instants; getting local wall-clock time right is just a matter of formatting those in the correct zone. Closing as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions