Add CurrentSecondsSinceEpoch for obtaining the current date and time - #6504
Draft
fingolfin wants to merge 1 commit into
Draft
Add CurrentSecondsSinceEpoch for obtaining the current date and time#6504fingolfin wants to merge 1 commit into
CurrentSecondsSinceEpoch for obtaining the current date and time#6504fingolfin wants to merge 1 commit into
Conversation
GAP so far has had no way to ask what time it is. NanosecondsSinceEpoch counts from an unspecified point -- CLOCK_MONOTONIC, or mach_absolute_time on macOS -- so despite its name it can measure a duration but cannot say when something happened. Packages that need a timestamp work around this by shelling out to `date` or by using IO_gettimeofday. CurrentSecondsSinceEpoch returns the number of seconds since 1970-01-01 00:00:00 UTC. That is the scale SecondsDMYhms and DMYhmsSeconds already use, so it composes with the calendar functions that are already there. Assistance from Claude Opus 5 via Claude Code: implementation, documentation and tests, reviewed by me. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
fingolfin
force-pushed
the
mh/current-time
branch
from
August 12, 2026 07:27
9c4d8f7 to
cff6f87
Compare
Member
Author
|
I've not yet reviewed this AI generated PR myself. So you may wish to hold off a review until I did so to avoid potentially being exposed to slop. |
fingolfin
marked this pull request as draft
August 12, 2026 12:45
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6504 +/- ##
==========================================
- Coverage 79.06% 79.05% -0.02%
==========================================
Files 685 685
Lines 293835 293836 +1
Branches 8666 8665 -1
==========================================
- Hits 232325 232296 -29
- Misses 59710 59735 +25
- Partials 1800 1805 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GAP cannot tell the time.
NanosecondsSinceEpochlooks like the answer butcounts from an unspecified point —
CLOCK_MONOTONIC, ormach_absolute_timeon macOS. Here
NanosecondsSinceEpoch()/10^9is 73750, the uptime.23 packages in the distribution handle dates;
yags,QGNAGand thelibsemigroupsbenchmarks shell out todate.CurrentSecondsSinceEpoch()returns seconds since 1970-01-01 00:00:00 UTC, soit feeds the calendar functions that already exist:
The epoch is guaranteed rather than assumed: POSIX pins
CLOCK_REALTIMEandgettimeofdayto 1970, and thetime()fallback converts viagmtime,checked against a C reference for every 86399-second step from 1970 to 2030.
The manual entry for
NanosecondsSinceEpochnow says it does not count from1970 and points here.
Naming.
CurrentSecondsSinceEpochnow sits besideNanosecondsSinceEpoch,which is not since the epoch.
CurrentUnixTimeandCurrentTimewere thealternatives; renaming is four lines.
make check: 0 failures in 314 files.Written with Claude Opus 5 via Claude Code; reviewed by me. The commit lists
the tool as co-author.