commit 447a12aef5ff1ccae1a5e7decdc9c023a0a0a284 parent baeacee8b7f64411eb53f13e4e31ba3f5364f265 Author: Byron Torres <b@torresjrjr.com> Date: Sun, 9 Jan 2022 00:10:58 +0000 add datetime::from_moment() Signed-off-by: Byron Torres <b@torresjrjr.com> Diffstat:
M | datetime/datetime.ha | | | 11 | ++++++++++- |
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/datetime/datetime.ha b/datetime/datetime.ha @@ -139,7 +139,16 @@ export fn clone(dt: datetime) datetime = { }; }; -// Converts a [[datetime]] to a [[chrono::moment]] +// Creates a [[datetime]] from a [[chrono::moment]] +export fn from_moment(m: chrono::moment) datetime = { + const dt = init(); + dt.date = m.date; + dt.time = m.time; + dt.loc = m.loc; + return dt; +}; + +// Creates a [[chrono::moment]] from a [[datetime]] export fn to_moment(dt: datetime) chrono::moment = { return chrono::moment { date = dt.date,