fix(zoned): fix timezoneid

This commit is contained in:
Nurul Huda (Apon) 2026-01-26 23:22:49 +06:00
parent 25d16f5671
commit a67d2e932c
No known key found for this signature in database
GPG key ID: 5D3F1DE2855A2F79

View file

@ -423,8 +423,11 @@ pub fn second(self: ZonedDateTime) u8 {
pub fn timeZoneId(self: ZonedDateTime, allocator: std.mem.Allocator) ![]u8 {
const tz = abi.c.temporal_rs_ZonedDateTime_timezone(self._inner);
const view = abi.fromDiplomatStringView(tz.normalized_id);
return try allocator.dupe(u8, view);
var write = abi.DiplomatWrite.init(allocator);
abi.c.temporal_rs_TimeZone_identifier(tz, &write.inner);
return try write.toOwnedSlice();
}
pub fn weekOfYear(self: ZonedDateTime) ?u8 {
@ -576,7 +579,7 @@ test "props" {
try std.testing.expectEqual(@as(u8, 0), zdt.second());
try std.testing.expectEqual(@as(u16, 0), zdt.millisecond());
// const tzo = try zdt.timeZoneId(std.testing.allocator);
// defer std.testing.allocator.free(tzo);
// try std.testing.expectEqualStrings("UTC", tzo);
const tzo = try zdt.timeZoneId(std.testing.allocator);
defer std.testing.allocator.free(tzo);
try std.testing.expectEqualStrings("UTC", tzo);
}