Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adjustments to the datetime library #6431

Merged
merged 22 commits into from
Jan 13, 2025

Conversation

algebraic-dev
Copy link
Contributor

@algebraic-dev algebraic-dev commented Dec 20, 2024

This PR fixes the Repr instance of the Timestamp type and changes the PlainTime type so that it always represents a clock time that may be a leap second.

  • Fix timestamp Repr.
  • The PlainTime type now always represents a clock time that may be a leap second.
  • Changed readlink -f to IO.FS.realPath

@algebraic-dev algebraic-dev requested a review from TwoFX as a code owner December 20, 2024 23:40
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Dec 20, 2024
@leanprover-community-bot
Copy link
Collaborator

leanprover-community-bot commented Dec 20, 2024

Mathlib CI status (docs):

  • ❗ Batteries CI can not be attempted yet, as the nightly-testing-2024-12-20 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-mathlib, Batteries CI should run now. (2024-12-20 23:58:12)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase e46b5f39bf77dffed3af8bfe154c73c2b772107f --onto 8d9d81453bd28aa9799e6bf2ad52def1d75549cb. (2025-01-02 21:03:01)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase e46b5f39bf77dffed3af8bfe154c73c2b772107f --onto 00ef231a6e03398c2ad3b577ab036f901ec88543. (2025-01-08 18:08:02)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase e46b5f39bf77dffed3af8bfe154c73c2b772107f --onto dd6445515ddc71826c76b8020fe9e030579b432b. (2025-01-09 22:32:12)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase e46b5f39bf77dffed3af8bfe154c73c2b772107f --onto d2c4471cfa4611977bf4927b5cd849df1a4272b7. (2025-01-10 23:11:34)

Copy link
Member

@tydeu tydeu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the leap change! Hopefully, I will eventually be able to swap out Lake's TOML implementation of DateTime for the Std one.

src/Std/Time/DateTime/PlainDateTime.lean Outdated Show resolved Hide resolved
src/Std/Time/Time/PlainTime.lean Outdated Show resolved Hide resolved
src/Std/Time/Zoned.lean Outdated Show resolved Hide resolved
src/Std/Time/Time/PlainTime.lean Outdated Show resolved Hide resolved
tests/lean/run/timeClassOperations.lean Outdated Show resolved Hide resolved
@algebraic-dev algebraic-dev requested a review from tydeu January 2, 2025 21:11
@kim-em
Copy link
Collaborator

kim-em commented Jan 8, 2025

@algebraic-dev, please remember to add changelog-* labels as needed. It's helpful for reviewers if the green CI check mark is present!

Copy link
Member

@TwoFX TwoFX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not like that PlainTime is parameterized now. I think that forcing dependent types on users here makes for bad ergonomics and it's very easy to have inconsistent APIs that are annoying to work around:

import Std.Time

open Std.Time

#eval PlainTime.fromLeanTime24Hour "12:00:00" -- Except.ok ⟨true, time("12:00:00.000000000")⟩
#eval PlainTime.now -- ⟨false, time("15:39:04.310660681")⟩

As far as ISO 8601 is concerned, there is only one kind of clock time -- the one you're calling PlainTime true/LeapTime.

I see two ways forward here:

  • carefully review the API, change all functions that currently return a Sigma PlainTime to return PlainTime true or PlainTime false and add conversion functions between PlainTime true and PlainTime false
  • Redefine PlainTime to what is called PlainTime true today.

I much prefer the second option, but I'm interested in everyone's opinions.

src/Std/Time/DateTime/Timestamp.lean Outdated Show resolved Hide resolved
src/Std/Time/Zoned/DateTime.lean Outdated Show resolved Hide resolved
tests/lean/run/timeAPI.lean Outdated Show resolved Hide resolved
@algebraic-dev algebraic-dev added the awaiting-review Waiting for someone to review the PR label Jan 9, 2025
@algebraic-dev
Copy link
Contributor Author

I preferred the second option and now the PlainTime makes Second.Offset true without a Sigma.

src/Std/Time/DateTime/PlainDateTime.lean Outdated Show resolved Hide resolved
src/Std/Time/DateTime/PlainDateTime.lean Outdated Show resolved Hide resolved
src/Std/Time/Time/PlainTime.lean Outdated Show resolved Hide resolved
src/Std/Time/Zoned.lean Outdated Show resolved Hide resolved
@TwoFX TwoFX added this pull request to the merge queue Jan 13, 2025
Merged via the queue into leanprover:master with commit 8483ac7 Jan 13, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review Waiting for someone to review the PR changelog-library Library toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants