Skip to content

Add CurrentSecondsSinceEpoch for obtaining the current date and time - #6504

Draft
fingolfin wants to merge 1 commit into
gap-system:masterfrom
fingolfin:mh/current-time
Draft

Add CurrentSecondsSinceEpoch for obtaining the current date and time#6504
fingolfin wants to merge 1 commit into
gap-system:masterfrom
fingolfin:mh/current-time

Conversation

@fingolfin

@fingolfin fingolfin commented Aug 12, 2026

Copy link
Copy Markdown
Member

GAP cannot tell the time. NanosecondsSinceEpoch looks like the answer but
counts from an unspecified point — CLOCK_MONOTONIC, or mach_absolute_time
on macOS. Here NanosecondsSinceEpoch()/10^9 is 73750, the uptime.

23 packages in the distribution handle dates; yags, QGNAG and the
libsemigroups benchmarks shell out to date.

CurrentSecondsSinceEpoch() returns seconds since 1970-01-01 00:00:00 UTC, so
it feeds the calendar functions that already exist:

gap> DMYhmsSeconds( CurrentSecondsSinceEpoch() );
[ 11, 8, 2026, 23, 14, 29 ]

The epoch is guaranteed rather than assumed: POSIX pins CLOCK_REALTIME and
gettimeofday to 1970, and the time() fallback converts via gmtime,
checked against a C reference for every 86399-second step from 1970 to 2030.

The manual entry for NanosecondsSinceEpoch now says it does not count from
1970 and points here.

Naming. CurrentSecondsSinceEpoch now sits beside NanosecondsSinceEpoch,
which is not since the epoch. CurrentUnixTime and CurrentTime were the
alternatives; 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.

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

Copy link
Copy Markdown
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
fingolfin marked this pull request as draft August 12, 2026 12:45
@fingolfin fingolfin added kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements topic: kernel release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes labels Aug 12, 2026
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.63636% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.05%. Comparing base (104ccfa) to head (cff6f87).

Files with missing lines Patch % Lines
src/gaptime.c 63.63% 2 Missing and 2 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes topic: kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant