-
Notifications
You must be signed in to change notification settings - Fork 438
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
base: master
Are you sure you want to change the base?
Conversation
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.
Thanks for the leap
change! Hopefully, I will eventually be able to swap out Lake's TOML implementation of DateTime
for the Std
one.
@@ -28,9 +28,16 @@ structure PlainDateTime where | |||
/-- | |||
The `Time` component of a `PlainTime` | |||
-/ | |||
time : PlainTime | |||
time : Sigma PlainTime |
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.
Did you consider also parameterizing PlainDateTime
by leap
as well?
|
||
namespace PlainTime | ||
|
||
/-- | ||
Creates a `PlainTime` value representing midnight (00:00:00.000000000). | ||
-/ | ||
def midnight : PlainTime := | ||
⟨0, 0, ⟨true, 0⟩, 0⟩ | ||
def midnight : PlainTime α := |
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.
What is the rational behind using α
and not leap
for this parameter in these definitions? It seems that a name of leap
would be better when users wish to set it using named parameters,
@@ -110,14 +111,14 @@ Converts a `PlainDate` to a `ZonedDateTime`. | |||
-/ | |||
@[inline] | |||
def ofPlainDate (pd : PlainDate) (zr : TimeZone.ZoneRules) : ZonedDateTime := | |||
ZonedDateTime.ofPlainDateTime (pd.atTime PlainTime.midnight) zr | |||
ZonedDateTime.ofPlainDateTime (pd.atTime (α := true) PlainTime.midnight) zr |
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.
For example, these uses of (α := true)
seem more readable as (leap := true)
.
/-- | ||
COMMENT | ||
-/ | ||
def LeapTime := PlainTime True |
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.
def LeapTime := PlainTime True | |
abbrev LeapTime := PlainTime True |
I imagine this is still TODO (given the COMMENT
), but I imagine this definitely should be an abbrev
rather than a def
to inherit the instances of PlainTime
.
@@ -65,7 +65,7 @@ info: datetime("2000-01-19T03:02:01.000000000") | |||
#guard_msgs in | |||
#eval datetime - (1 : Day.Offset) | |||
|
|||
def time := time("13:02:01") | |||
def time : PlainTime true := time("13:02:01") |
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.
def time : PlainTime true := time("13:02:01") | |
def time : LeapTime := time("13:02:01") |
Maybe use this here and elsewhere (instead of PlainTime true
)?
This PR fix some issues that I found while using the library and other things that some people suggested
Repr
.LeapTime
and changedPlainTime : Type
toPlainType : (leap : Bool) -> Type
readlink -f
toIO.FS.realPath