-
Notifications
You must be signed in to change notification settings - Fork 321
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
Builtin Date_Time, Time_Of_Day, Zone #3658
Conversation
engine/runtime/src/main/java/org/enso/interpreter/runtime/data/EnsoZone.java
Outdated
Show resolved
Hide resolved
std-bits/table/src/main/java/org/enso/table/formatting/TimeFormatter.java
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/type/Types.java
Show resolved
Hide resolved
...ne/runtime/src/main/java/org/enso/interpreter/node/callable/resolver/HostMethodCallNode.java
Show resolved
Hide resolved
...ne/runtime/src/main/java/org/enso/interpreter/node/callable/resolver/HostMethodCallNode.java
Outdated
Show resolved
Hide resolved
distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Zone.enso
Outdated
Show resolved
Hide resolved
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.
Looks great to me overall. Some observations inline.
0434f47
to
7a11d4d
Compare
0df919c
to
7802603
Compare
distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Time_Of_Day.enso
Outdated
Show resolved
Hide resolved
Integer -> self.make_integer_parser | ||
Decimal -> self.make_decimal_parser | ||
Boolean -> self.make_boolean_parser | ||
_ -> | ||
if datatype == Date then self.make_date_parser else | ||
if datatype == Time then self.make_datetime_parser else | ||
if datatype == Time_Of_Day then self.make_time_parser else | ||
Error.throw (Illegal_Argument_Error "Unsupported datatype: "+datatype.to_text) | ||
Integer -> self.make_integer_parser | ||
Decimal -> self.make_decimal_parser | ||
Boolean -> self.make_boolean_parser | ||
Date -> self.make_date_parser | ||
Date_Time -> self.make_datetime_parser | ||
Time_Of_Day -> self.make_time_parser | ||
_ -> Error.throw (Illegal_Argument_Error "Unsupported datatype: "+datatype.to_text) | ||
|
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.
❤️
engine/runtime/src/main/java/org/enso/interpreter/runtime/data/EnsoDateTime.java
Outdated
Show resolved
Hide resolved
std-bits/table/src/main/java/org/enso/table/formatting/TimeFormatter.java
Outdated
Show resolved
Hide resolved
Improved polyglot support for Date_Time (formerly Time), Time_Of_Day and Zone. This follows the pattern introduced for Enso Date. Minor caveat - in tests for Date, had to bend a lot for JS Date to pass. This is because JS Date is not really only a Date, but also a Time and Timezone, previously we just didn't consider the latter. Also, JS Date does not deal well with setting timezones so the trick I used is to first call foreign function returning a polyglot JS Date, which is converted to ZonedDateTime and only then set the correct timezone. That way none of the existing tests had to be changes or special cased. Additionally, JS deals with milliseconds rather than nanoseconds so there is loss in precision, as noted in Time_Spec.
Column reader didn't take into account timezone but that was a mistake since then it wouldn't map to Enso's Date_Time. Added tests that check it now.
Co-authored-by: Radosław Waśko <radoslaw.wasko@enso.org>
bee9a17
to
c761487
Compare
@radeusgd I think I addressed all your comments |
...ne/runtime/src/main/java/org/enso/interpreter/node/callable/resolver/HostMethodCallNode.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/data/EnsoDateTime.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
@Builtin.Method(description = "Return the number of seconds from the Unix epoch.") | ||
public long toEpochSeconds() { |
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.
My recent experience with @TruffleBoundary
suggests that many of these methods shall be behind the boundary.
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 can add some, but at the moment without any gatekeepers it feels like a slightly random process.
engine/runtime/src/main/java/org/enso/interpreter/runtime/data/EnsoDateTime.java
Show resolved
Hide resolved
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 this @hubertp - this gives us a fantastic base to build on to build out the functions we need.
Pull Request Description
Improved polyglot support for Date_Time (formerly Time), Time_Of_Day and
Zone. This follows the pattern introduced for Enso Date.
Related to https://www.pivotaltracker.com/story/show/182973664 and https://www.pivotaltracker.com/n/projects/2539304/stories/182987210
Important Notes
Minor caveat - in tests for Date, had to bend a lot for JS Date to pass.
This is because JS Date is not really only a Date, but also a Time and
Timezone, previously we just didn't consider the latter.
Also, JS Date does not deal well with setting timezones so the trick I
used is to first call foreign function returning a polyglot JS Date,
which is converted to ZonedDateTime and only then set the correct
timezone. That way none of the existing tests had to be changed or
special cased.
Additionally, JS deals with milliseconds rather than nanoseconds so
there is loss in precision, as noted in Time_Spec.
Checklist
Please include the following checklist in your PR:
Scala,
Java,
and
Rust
style guides.
./run ide build
and./run ide watch
.