diff --git a/core/encoding/uuid/reading.odin b/core/encoding/uuid/reading.odin index d41606f63de..ab08300b060 100644 --- a/core/encoding/uuid/reading.odin +++ b/core/encoding/uuid/reading.odin @@ -163,8 +163,7 @@ Returns: - timestamp: The timestamp of the UUID. */ time_v1 :: proc "contextless" (id: Identifier) -> (timestamp: time.Time) { - delta := cast(time.Duration)(raw_time_v1(id) - HNS_INTERVALS_BETWEEN_GREG_AND_UNIX) * 100 - return time.time_add({}, delta) + return { _nsec = cast(i64)(raw_time_v1(id) - HNS_INTERVALS_BETWEEN_GREG_AND_UNIX) * 100 } } /* @@ -195,8 +194,7 @@ Returns: - timestamp: The timestamp, in 100-nanosecond intervals since 1582-10-15. */ time_v6 :: proc "contextless" (id: Identifier) -> (timestamp: time.Time) { - delta := cast(time.Duration)(raw_time_v6(id) - HNS_INTERVALS_BETWEEN_GREG_AND_UNIX) * 100 - return time.time_add({}, delta) + return { _nsec = cast(i64)(raw_time_v6(id) - HNS_INTERVALS_BETWEEN_GREG_AND_UNIX) * 100 } } /* @@ -223,7 +221,7 @@ Returns: - timestamp: The timestamp, in milliseconds since the UNIX epoch. */ time_v7 :: proc "contextless" (id: Identifier) -> (timestamp: time.Time) { - return time.time_add({}, cast(time.Duration)(raw_time_v7(id) * 1e6)) + return { _nsec = cast(i64)raw_time_v7(id) * 1e6 } } /* diff --git a/tests/core/encoding/uuid/test_core_uuid.odin b/tests/core/encoding/uuid/test_core_uuid.odin index 9f66b316d25..619534a7fb5 100644 --- a/tests/core/encoding/uuid/test_core_uuid.odin +++ b/tests/core/encoding/uuid/test_core_uuid.odin @@ -144,9 +144,9 @@ test_legacy_namespaced_uuids :: proc(t: ^testing.T) { test_v1 :: proc(t: ^testing.T) { context.random_generator = crypto.random_generator() - point_a := time.time_add({}, 1 * time.Second) - point_b := time.time_add({}, 3 * time.Second) - point_c := time.time_add({}, 5 * time.Second) + point_a := time.unix(1, 0) + point_b := time.unix(3, 0) + point_c := time.unix(5, 0) CLOCK :: 0x3A1A mac := [6]u8{0xFF, 0x10, 0xAA, 0x55, 0x01, 0xFF} @@ -179,9 +179,9 @@ test_v1 :: proc(t: ^testing.T) { test_v6 :: proc(t: ^testing.T) { context.random_generator = crypto.random_generator() - point_a := time.time_add({}, 1 * time.Second) - point_b := time.time_add({}, 3 * time.Second) - point_c := time.time_add({}, 5 * time.Second) + point_a := time.unix(1, 0) + point_b := time.unix(3, 0) + point_c := time.unix(5, 0) CLOCK :: 0x3A1A mac := [6]u8{0xFF, 0x10, 0xAA, 0x55, 0x01, 0xFF} @@ -214,9 +214,9 @@ test_v6 :: proc(t: ^testing.T) { test_v7 :: proc(t: ^testing.T) { context.random_generator = crypto.random_generator() - point_a := time.time_add({}, 1 * time.Second) - point_b := time.time_add({}, 3 * time.Second) - point_c := time.time_add({}, 5 * time.Second) + point_a := time.unix(1, 0) + point_b := time.unix(3, 0) + point_c := time.unix(5, 0) v7_a := uuid.generate_v7(point_a) v7_b := uuid.generate_v7(point_b) @@ -245,11 +245,11 @@ test_sorting_v1 :: proc(t: ^testing.T) { // They are incapable of sorting properly by the nature their time bit ordering. // // Something is very strange if they do sort correctly. - point_a := time.time_add({}, 1 * time.Second) - point_b := time.time_add({}, 3 * time.Second) - point_c := time.time_add({}, 5 * time.Second) - point_d := time.time_add({}, 7 * time.Second) - point_e := time.time_add({}, 11 * time.Second) + point_a := time.unix(1, 0) + point_b := time.unix(3, 0) + point_c := time.unix(5, 0) + point_d := time.unix(7, 0) + point_e := time.unix(11, 0) mac: [6]byte v1_a := uuid.generate_v1(0, mac, point_a) @@ -283,11 +283,11 @@ test_sorting_v1 :: proc(t: ^testing.T) { test_sorting_v6 :: proc(t: ^testing.T) { context.random_generator = crypto.random_generator() - point_a := time.time_add({}, 1 * time.Second) - point_b := time.time_add({}, 3 * time.Second) - point_c := time.time_add({}, 5 * time.Second) - point_d := time.time_add({}, 7 * time.Second) - point_e := time.time_add({}, 11 * time.Second) + point_a := time.unix(1, 0) + point_b := time.unix(3, 0) + point_c := time.unix(5, 0) + point_d := time.unix(7, 0) + point_e := time.unix(11, 0) mac: [6]byte v6_a := uuid.generate_v6(0, mac, point_a) @@ -326,11 +326,11 @@ test_sorting_v6 :: proc(t: ^testing.T) { test_sorting_v7 :: proc(t: ^testing.T) { context.random_generator = crypto.random_generator() - point_a := time.time_add({}, 1 * time.Second) - point_b := time.time_add({}, 3 * time.Second) - point_c := time.time_add({}, 5 * time.Second) - point_d := time.time_add({}, 7 * time.Second) - point_e := time.time_add({}, 11 * time.Second) + point_a := time.unix(1, 0) + point_b := time.unix(3, 0) + point_c := time.unix(5, 0) + point_d := time.unix(7, 0) + point_e := time.unix(11, 0) v7_a := uuid.generate_v7(point_a) v7_b := uuid.generate_v7(point_b)