diff options
Diffstat (limited to 'stdlib')
| -rw-r--r-- | stdlib/integers.h | 3 | ||||
| -rw-r--r-- | stdlib/moments.c | 4 | ||||
| -rw-r--r-- | stdlib/moments.h | 2 |
3 files changed, 6 insertions, 3 deletions
diff --git a/stdlib/integers.h b/stdlib/integers.h index 5556c19c..1ebc30aa 100644 --- a/stdlib/integers.h +++ b/stdlib/integers.h @@ -360,6 +360,9 @@ CONVERSION_FUNC(16, 8) if (__builtin_expect(!truncate && (num##_t)(int_type##_t)rounded != rounded, 0)) \ fail("Cannot truncate the " #num " %g to an " #int_type, (double)rounded); \ return (int_type##_t)rounded; \ + } \ + MACROLIKE PUREFUNC num##_t int_type##_to_##num(int_type##_t n) { \ + return (num##_t)n; \ } CONVERSION_FUNC(Num, Int64) diff --git a/stdlib/moments.c b/stdlib/moments.c index e83bae57..e1f59606 100644 --- a/stdlib/moments.c +++ b/stdlib/moments.c @@ -54,7 +54,7 @@ public Moment_t Moment$now(void) struct timespec ts; if (clock_gettime(CLOCK_REALTIME, &ts) != 0) fail("Couldn't get the time!"); - return (Moment_t){.tv_sec=ts.tv_sec, .tv_usec=ts.tv_nsec}; + return (Moment_t){.tv_sec=ts.tv_sec, .tv_usec=ts.tv_nsec/1000}; } public Moment_t Moment$new(Int_t year, Int_t month, Int_t day, Int_t hour, Int_t minute, double second, OptionalText_t timezone) @@ -180,7 +180,7 @@ public Int_t Moment$second(Moment_t moment, OptionalText_t timezone) return I(info.tm_sec); } -public Int_t Moment$nanosecond(Moment_t moment, OptionalText_t timezone) +public Int_t Moment$microsecond(Moment_t moment, OptionalText_t timezone) { (void)timezone; return I(moment.tv_usec); diff --git a/stdlib/moments.h b/stdlib/moments.h index 48899b8b..1ae33269 100644 --- a/stdlib/moments.h +++ b/stdlib/moments.h @@ -26,7 +26,7 @@ Int_t Moment$day_of_year(Moment_t moment, OptionalText_t timezone); Int_t Moment$hour(Moment_t moment, OptionalText_t timezone); Int_t Moment$minute(Moment_t moment, OptionalText_t timezone); Int_t Moment$second(Moment_t moment, OptionalText_t timezone); -Int_t Moment$nanosecond(Moment_t moment, OptionalText_t timezone); +Int_t Moment$microsecond(Moment_t moment, OptionalText_t timezone); Text_t Moment$format(Moment_t moment, Text_t fmt, OptionalText_t timezone); Text_t Moment$date(Moment_t moment, OptionalText_t timezone); Text_t Moment$time(Moment_t moment, bool seconds, bool am_pm, OptionalText_t timezone); |
