-
Notifications
You must be signed in to change notification settings - Fork 434
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
feat: add date and time functionality #4904
Conversation
leanprover-community-mathlib4-bot
commented
Aug 5, 2024
•
edited by leanprover-community-bot
Loading
edited by leanprover-community-bot
Mathlib CI status (docs):
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add tests for the various conversion routines that catch all of the interesting cases.
It would be very nice to have a few examples of the library being used in practice to achieve some common things.
A very minor suggestion for an in-Lean use case: have the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gentle reminder that we will not be able to merge this until there are decent tests for much of the functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
private def convertText : Text → MacroM (TSyntax `term) | ||
| .short => `(Std.Time.Text.short) | ||
| .full => `(Std.Time.Text.full) | ||
| .narrow => `(Std.Time.Text.narrow) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be Lean.Quote
instances?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried once but I saw that I would need a function called Unhygienic.run
that I think that is inside Lean.Hygienic
. AFAIK I cannot import lean things on std because it would lead to some dependency order problems.
private def convertPlainDateTime (d : Std.Time.PlainDateTime) : MacroM (TSyntax `term) := do | ||
`(Std.Time.PlainDateTime.mk $(← convertPlainDate d.date) $(← convertPlainTime d.time)) | ||
|
||
private def convertZonedDateTime (d : Std.Time.ZonedDateTime) (identifier := false) : MacroM (TSyntax `term) := do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking one more time about this, I think all this is maybe really Lean.ToExpr
instead? Maybe @kmill has some thoughts here.
Hi @eric-wieser, thank you for taking the time to read through the PR. Our current priorities are to get the public API right and to get the PR merged. As far as I understand (please correct me if I'm wrong), your comments about |
Agreed
I don't agree, the |
Thanks, I had missed this. I agree that the |
let mut quadracentennialCycles := days / daysPer400Y; | ||
let mut remDays := days.val % daysPer400Y.val; | ||
let mut quadracentennialCycles := days.val / daysPer400Y; | ||
let mut remDays := days.val % daysPer400Y; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Adding a Mod
operation for UnitVal
would be well-typed, and would clean this up a little.
This PR introduces date and time functionality to the Lean 4 Std.
Breaking Changes:
Lean.Data.Rat
is nowStd.Internal.Rat
because it's used by the DateTime library.