Skip to content

Commit dcedbd8

Browse files
author
Florian Thake
committed
CORELIB: clock_utc() now returns always the UTC time in system clock representation.
- This is a breaking change on Windows and Linux with gcc >= 13. The leap seconds are not counted anymore. Thus, the annoying offset to the system time is gone.
1 parent 893c95b commit dcedbd8

3 files changed

Lines changed: 10 additions & 16 deletions

File tree

Deprecation_and_Breaking_Changes.txt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ TeaScript Breaking Changes in the actual release
33

44
Changes in CoreLibrary functionality
55
------------------------------------
6+
clock_utc() has a breaking change on Windows and Linux with gcc >= 13.
7+
clock_utc() now returns always the UTC time in system clock representation.
8+
On Windows and on Linux with GCC >= 13 this is a breaking change since the leap seconds are not counted anymore.
9+
The previous wrong behavior resulted due to a misunderstanding of the underlying C++ API.
10+
Now there isn't an annoying offset to the system clock time anymore.
611

712

813
Changes on C++ API level
@@ -24,13 +29,6 @@ TeaScript list of deprecated parts
2429
=================================================
2530

2631
The following deprecated parts have been finally removed from this release:
27-
28-
exit( exit_code )
29-
use either _exit( Any ) or the new _Exit statement instead.
30-
A script will always have a result or NaV (Not A Value).
31-
32-
class Engine HasExitCode()/GetExitCode() and mExitCode
33-
A script will always have a result or NaV (Not A Value).
3432

3533

3634
The following parts are now deprecated and will be removed in some future release:

Known_Issues.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ NOTE: The numbers stay same, solved items will (usually) be removed in the next
2121
a total strong ordering will be performed and the values can be compared.
2222

2323

24-
8.) [PLATFORM: Linux with clang or gcc < 13]
25-
CoreLibrary function clock_utc() will return UTC time _without_ leap seconds.
26-
WORKAROUND: Use gcc >= 13 on Linux.
24+
8.) Solved! This issue was a misunderstanding of std::chrono::utc_clock.
25+
Now, on all platforms clock_utc() returns the UTC time in system_clock representation.
2726

2827

2928
10.) [PLATFORM: any]

include/teascript/CoreLibrary.hpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,11 @@ class CoreLibrary
262262
#endif
263263
}
264264

265-
/// gets the UTC time in fractional seconds (with leap seconds!).
265+
/// gets the UTC time in fractional seconds.
266266
static double GetUTCTimeInSecs()
267267
{
268-
#if _MSC_VER || (!defined(__clang__) && __GNUC__ >= 13 ) // TODO: _LIBCPP_VERSION
269-
auto const now = std::chrono::utc_clock::now(); // UTC with leap seconds.
270-
#else
268+
// NOTE: std::chrono::utc_clock::now() is with(!) leap seconds. If use this for time representation it will be in the 'future' of the system clock!
271269
auto const now = std::chrono::system_clock::now(); // UTC without(!) leap seconds.
272-
#endif
273270
std::chrono::duration<double> const timesecs = now - std::chrono::floor<std::chrono::days>( now );
274271
return timesecs.count();
275272
}
@@ -1940,7 +1937,7 @@ class CoreLibrary
19401937
tea_add_var( "clock", std::move( val ) ); // missing _ is intended for now.
19411938
}
19421939

1943-
// clock_utc : f64 ( void ) --> gets the UTC time of the current day in (fractional) seconds as f64. (note: This UTC time is with leap seconds!)
1940+
// clock_utc : f64 ( void ) --> gets the UTC time of the current day in (fractional) seconds as f64.
19441941
{
19451942
auto func = std::make_shared< LibraryFunction0< decltype(GetUTCTimeInSecs), double > >( &GetUTCTimeInSecs );
19461943
ValueObject val{std::move( func ), cfg_mutable};

0 commit comments

Comments
 (0)