Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #124806 > unrolled thread

How to print all days with leap seconds with C++

Started byBonita Montero <Bonita.Montero@gmail.com>
First post2026-09-11 19:43 +0200
Last post2026-09-12 05:18 +0200
Articles 3 — 2 participants

Back to article view | Back to comp.lang.c++


Contents

  How to print all days with leap seconds with C++ Bonita Montero <Bonita.Montero@gmail.com> - 2026-09-11 19:43 +0200
    Re: How to print all days with leap seconds with C++ scott@slp53.sl.home (Scott Lurndal) - 2026-09-11 18:21 +0000
      Re: How to print all days with leap seconds with C++ Bonita Montero <Bonita.Montero@gmail.com> - 2026-09-12 05:18 +0200

#124806 — How to print all days with leap seconds with C++

FromBonita Montero <Bonita.Montero@gmail.com>
Date2026-09-11 19:43 +0200
SubjectHow to print all days with leap seconds with C++
Message-ID<1181ekc$33tbf$1@raubtier-asyl.eternal-september.org>
#include <iostream>
#include <chrono>

using namespace std;
using namespace chrono;

int main()
{
	for( int yr = 1972; yr < 2035; ++yr )
		for( int dec31 = 0; dec31 <= 1; ++dec31 )
		{
			year_month_day ymd = year( yr + dec31 ) / month( dec31 ? 1 : 7 ) / 
day( 1 );
			system_clock::time_point
				tpAfter = sys_days( ymd ),
				tpBefore = tpAfter - system_clock::duration( 1 );
			utc_clock::time_point
				utcBefore = utc_clock::from_sys( tpBefore ),
				utcAfter = utc_clock::from_sys( tpAfter );
			if( utcAfter - utcBefore >= 1s )
				cout << yr << " / " << (dec31 ? "december" : "june") << endl;
		}
}

[toc] | [next] | [standalone]


#124807

Fromscott@slp53.sl.home (Scott Lurndal)
Date2026-09-11 18:21 +0000
Message-ID<2FXoS.789$NE2.169@fx20.iad>
In reply to#124806
Bonita Montero <Bonita.Montero@gmail.com> writes:

>int main()
>{
>	for( int yr = 1972; yr < 2035; ++yr )

1. Might as well stop at 2026, as there will likely be no
   additional leap seconds added after that [*]

2. On 64-bit linux, time_t is 64_bits; stopping at 2034
   is only meaningful for 32-bit time_t.

[*]<https://www.theregister.com/offbeat/2026/09/06/time-lords-prepare-to-kick-leap-seconds-into-the-next-millennium/5294538>

[toc] | [prev] | [next] | [standalone]


#124809

FromBonita Montero <Bonita.Montero@gmail.com>
Date2026-09-12 05:18 +0200
Message-ID<1182g9u$3e6tk$1@raubtier-asyl.eternal-september.org>
In reply to#124807
Am 11.09.2026 um 20:21 schrieb Scott Lurndal:
> Bonita Montero <Bonita.Montero@gmail.com> writes:
> 
>> int main()
>> {
>> 	for( int yr = 1972; yr < 2035; ++yr )
> 
> 1. Might as well stop at 2026, as there will likely be no
>     additional leap seconds added after that [*]
> 
> 2. On 64-bit linux, time_t is 64_bits; stopping at 2034
>     is only meaningful for 32-bit time_t.
There will be no more leap seconds from 2035 on.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.c++


csiph-web