hare

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

commit 25281e18bfb499b821f97a8e92572639273c33db
parent 865184b2dad4fa04612f56eb0d642b47b6044e48
Author: Byron Torres <b@torresjrjr.com>
Date:   Tue, 25 Jan 2022 23:54:53 +0000

improve and fix %z

Diffstat:
Mdatetime/format.ha | 10++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/datetime/format.ha b/datetime/format.ha @@ -261,8 +261,14 @@ fn fmt_specifier(r: rune, dt: *datetime) (str | errors::invalid | io::error) = { yield strconv::itos(year(dt)); case 'z' => // TODO: test - const z = calc_hmsn(dt.zone.zoffset); - yield fmt::asprintf("{:+02}{:02}", z.0, z.1); + let pm = '+'; + const z = if (dt.zone.zoffset >= 0) { + yield calc_hmsn(dt.zone.zoffset); + } else { + pm = '-'; + yield calc_hmsn(-dt.zone.zoffset); + }; + yield fmt::asprintf("{}{:02}{:02}", pm, z.0, z.1); case 'Z' => yield dt.zone.abbr; case '%' =>