hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit d4fcbc4b07eafa24b0ad71358a93955c7aa86720
parent 0fe4ba01727c6e0a448f9a6565c7159e0011914e
Author: Byron Torres <b@torresjrjr.com>
Date:   Thu,  7 Mar 2024 00:14:03 +0000

time::date: rename nowutc(), now(), use localnow()

Rename [[now]] to [[localnow]].
Rename [[nowutc]] to [[now]].

Breaking-Change: 0.24.0
Signed-off-by: Byron Torres <b@torresjrjr.com>

Diffstat:
Mlog/logger.ha | 4++--
Mtime/date/README | 2+-
Mtime/date/date.ha | 10+++++-----
3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/log/logger.ha b/log/logger.ha @@ -29,7 +29,7 @@ export fn new(sink: io::handle) stdlogger = { fn log_println(sink: *logger, fields: fmt::formattable...) void = { const sink = sink: *stdlogger; assert(sink.println == &log_println); - const now = date::now(); + const now = date::localnow(); fmt::fprint(sink.sink, "["): void; date::format(sink.sink, date::STAMP, &now): void; fmt::fprint(sink.sink, "] "): void; @@ -39,7 +39,7 @@ fn log_println(sink: *logger, fields: fmt::formattable...) void = { fn log_printfln(sink: *logger, fmt: str, fields: fmt::field...) void = { const sink = sink: *stdlogger; assert(sink.printfln == &log_printfln); - const now = date::now(); + const now = date::localnow(); fmt::fprint(sink.sink, "["): void; date::format(sink.sink, date::STAMP, &now): void; fmt::fprint(sink.sink, "] "): void; diff --git a/time/date/README b/time/date/README @@ -5,7 +5,7 @@ civil date/time and a optimized extension of the [[time::chrono::moment]] type. The [[time::chrono::]] module has many useful functions which interoperate with dates. Any [[time::chrono::]] function which accepts *moment also accepts *date. -Dates are created using [[new]], [[now]], [[nowutc]], or a "from_" function. +Dates are created using [[new]], [[now]], [[localnow]], or a "from_" function. Alternatively, the [[virtual]]/[[realize]] interface can handle uncertain or invalid date/time information, and construct new dates incrementally and safely. The observer functions ([[year]], [[hour]], etc.) evaluate a date's observed diff --git a/time/date/date.ha b/time/date/date.ha @@ -189,15 +189,15 @@ export fn new( }; // Returns a [[date]] of the current system time using -// [[time::clock::REALTIME]], in the [[time::chrono::LOCAL]] locality. +// [[time::clock::REALTIME]], in the [[time::chrono::UTC]] locality. export fn now() date = { - return from_instant(chrono::LOCAL, time::now(time::clock::REALTIME)); + return from_instant(chrono::UTC, time::now(time::clock::REALTIME)); }; // Returns a [[date]] of the current system time using -// [[time::clock::REALTIME]], in the [[time::chrono::UTC]] locality. -export fn nowutc() date = { - return from_instant(chrono::UTC, time::now(time::clock::REALTIME)); +// [[time::clock::REALTIME]], in the [[time::chrono::LOCAL]] locality. +export fn localnow() date = { + return from_instant(chrono::LOCAL, time::now(time::clock::REALTIME)); }; // Creates a [[date]] from a [[time::chrono::moment]].