Calculating a local time interval with C++ Chrono
07:01 11 Jun 2026

I have a time-series that I am demarcating at arbitrary points defined as the number of seconds since Sunday midnight local time for a given week.

The timestamps within a series are recorded as the number of milliseconds that have elapsed since January 1, 1970 (midnight UTC).

For example one such time-series has the timezone America/New_York lets demarcate the first interval starting at 64860 and ending at 147540 seconds past Sunday midnight - aka 6pm Sunday through to 5pm Monday.

for the following weeks beginning:

  • Sun, 2 Nov 2025 - note that local clocks were turned backward - 1 hour at 2am to 1am due to dst ending.

  • Sun, 8 Mar 2026 - note that local clocks were turned forward - 1 hour at 2am to 3am due to dst starting.

WEEK1

Midnight:

Sun, 2 Nov 2025, 0:00:00 in time zone America/New York (EDT)

is 1762056000 UTC with offset -04:00 (-14400 seconds). - This datetime is in daylight saving time.

START:

Sun, 2 Nov 2025, 18:01:00 in time zone America/New York (EST)

is 1762124460 UTC with offset -05:00 (-18000 seconds). - no longer DST

END:

Mon, 3 Nov 2025, 16:59:00 in time zone America/New York (EST)

is 1762207140 UTC with offset -05:00 (-18000 seconds).

WEEK2

Midnight:

Sun, 8 Mar 2026, 0:00:00 in time zone America/New York (EST)

is 1772946000 UTC with offset -05:00 (-18000 seconds). - this datetime is not in daylight savings time

START:

Sun, 8 Mar 2026, 18:01:00 in time zone America/New York (EDT)

is 1773007260 UTC with offset -04:00 (-14400 seconds). - This datetime is in daylight saving time.

END:

Mon, 9 Mar 2026, 16:59:00 in time zone America/New York (EDT)

is 1773089940 UTC with offset -04:00 (-14400 seconds).

The code below is my current attempt to calculate the interval start and end timestamps:

#include 

#include 

auto week_begining(std::chrono::milliseconds timestamp, std::string_view scheduleTimeZone)
{
    // get zoned_time for previous SUNDAY 00:00 local time

    using namespace std::chrono;

    // timepoint based on utc
    auto tp = system_clock::time_point( timestamp );

    // zoned timepoint
    auto tz = locate_zone(scheduleTimeZone);
    std::chrono::zoned_time zt{tz,  tp};

    auto local_time = zt.get_local_time();
    auto local_date = floor( local_time );

    // count back to Sunday
    auto days_ago = weekday{local_date} - Sunday;
    auto sunday = local_date - days_ago;


return sunday;
}


int main()
{
    using namespace std::chrono;

    auto sunday = week_begining( milliseconds(1762146000000), "America/New_York");

    // not in local time ? 
    auto start = sunday + seconds(64860);
    auto end   = sunday + seconds(147540);

    std::cout << std::chrono::duration_cast(start.time_since_epoch()).count() << std::endl;
    std::cout << std::chrono::duration_cast(end.time_since_epoch()).count() << std::endl;
    return 0;
}

this returns the incorrect output below:

1762106460000
1762189140000

How should I go about calculating a local time intervals UTC time ?

c++-chrono