-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring and now method in Instant
- Loading branch information
Showing
5 changed files
with
48 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use "time" | ||
|
||
interface Clock | ||
fun now(): (I64 /*sec*/, U32 /*nsec*/) | ||
|
||
class SystemClock is Clock | ||
|
||
fun now(): (I64 /*sec*/, U32 /*nsec*/) => | ||
let n = Time.now() | ||
(n._1, n._2.u32()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
primitive MillisPerSecond fun apply(): U32 => 1_000 | ||
primitive MillisPerMinute fun apply(): U32 => SecondsPerMinute().u32() * MillisPerSecond() | ||
primitive MillisPerHour fun apply(): U32 => MillisPerMinute() * MinutesPerHour().u32() | ||
primitive NanosPerSecond fun apply(): U32 => 1_000_000_000 | ||
primitive NanosPerMilli fun apply(): U32 => 1_000_000 | ||
primitive NanosPerMinute fun apply(): U64 => NanosPerSecond().u64() * SecondsPerMinute().u64() | ||
primitive NanosPerHour fun apply(): U64 => NanosPerSecond().u64() * SecondsPerHour().u64() | ||
primitive SecondsPerMinute fun apply(): U16 => 60 | ||
primitive SecondsPerHour fun apply(): U16 => SecondsPerMinute() * MinutesPerHour() | ||
primitive MinutesPerHour fun apply(): U16 => 60 | ||
primitive HoursPerDay fun apply(): U16 => 24 | ||
primitive MinutesPerDay fun apply(): U16 => MinutesPerHour() * HoursPerDay() | ||
primitive SecondsPerDay fun apply(): U32 => SecondsPerMinute().u32() * MinutesPerDay().u32() | ||
|
||
/** | ||
* The number of days from year zero to year 1970. | ||
* There are five 400 year cycles from year zero to 2000. | ||
* There are 7 leap years from 1970 to 2000. | ||
*/ | ||
primitive DaysSinceEpoch fun apply(): U32 => (DaysPer400YearCycle() * 5) - ((30 * 365) + 7) | ||
primitive DaysPer400YearCycle fun apply(): U32 => 146097 |
This file was deleted.
Oops, something went wrong.
575e48e
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.
as Pony currently lacks constructing dates from parts, this library is cool. Thanks! Planning to use it vendored here for now