Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: flysand7 <[email protected]>
  • Loading branch information
c-cube and flysand7 committed Sep 22, 2024
1 parent d08b3d3 commit 32e13f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions core/time/rfc3339.odin
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ time_to_rfc3339 :: proc(time: Time, utc_offset : int = 0, include_nanos := true,

if datetime.year < 0 || datetime.year >= 10_000 { return "", false }

temp_string := [30]u8{}
offset : uint = 0 // offset in temp_string
temp_string := [36]u8{}
offset : uint = 0

print_as_fixed_int :: proc(dst: []u8, offset: ^uint, width: i8, i: i64) {
i := i
Expand Down Expand Up @@ -275,7 +275,7 @@ time_to_rfc3339 :: proc(time: Time, utc_offset : int = 0, include_nanos := true,
offset += 1
} else {
temp_string[offset] = utc_offset > 0 ? '+' : '-'
offset += 1;
offset += 1
utc_offset := abs(utc_offset)
print_as_fixed_int(temp_string[:], &offset, 2, i64(utc_offset / 60))
temp_string[offset] = ':'
Expand Down
5 changes: 3 additions & 2 deletions tests/core/time/test_core_time.odin
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ test_print_rfc3339 :: proc(t: ^testing.T) {
TestCase :: struct {
printed: string,
time: i64,
utc_offset: int
utc_offset: int,
};

tests :: [?]TestCase {
Expand All @@ -221,7 +221,8 @@ test_print_rfc3339 :: proc(t: ^testing.T) {

testing.expectf(
t, printed_timestamp == test.printed,
"expected is %w, printed is %w", test.printed, printed_timestamp)
"expected is %w, printed is %w", test.printed, printed_timestamp,
)
}
}

Expand Down

0 comments on commit 32e13f1

Please sign in to comment.