diff options
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | lib/uuid/uuid.tm | 11 |
2 files changed, 8 insertions, 5 deletions
@@ -137,7 +137,7 @@ install: build/tomo build/$(LIB_FILE) rm -f "$(PREFIX)/bin/tomo" cp -v build/tomo "$(PREFIX)/bin/" cp -v docs/tomo.1 "$(PREFIX)/man/man1/" - ./build/tomo -qIL lib/patterns lib/time lib/commands lib/shell lib/random lib/base64 lib/pthreads lib/core + ./build/tomo -qIL lib/patterns lib/time lib/commands lib/shell lib/random lib/base64 lib/pthreads lib/uuid lib/core uninstall: rm -rvf "$(PREFIX)/bin/tomo" "$(PREFIX)/include/tomo" "$(PREFIX)/lib/$(LIB_FILE) "$(PREFIX)/share/tomo"; \ diff --git a/lib/uuid/uuid.tm b/lib/uuid/uuid.tm index 002b4808..06d48390 100644 --- a/lib/uuid/uuid.tm +++ b/lib/uuid/uuid.tm @@ -1,3 +1,6 @@ +use random +use time + lang UUID func v4(-> UUID) # Random UUID bytes := &random.bytes(16) @@ -8,8 +11,8 @@ lang UUID return UUID.from_text(uuid) func v7(-> UUID) # Timestamp + random UUID - n := now() - timestamp := n.seconds*1000 + n.microseconds/1_000 + n := Time.now() + timestamp := n.tv_sec*1000 + n.tv_usec/1_000 bytes := [ Byte((timestamp >> 40)), @@ -31,6 +34,6 @@ lang UUID enum UUIDVersion(v4, v7) func main(version=UUIDVersion.v7) when version is v4 - say(UUID.v4().text_content) + say(UUID.v4().text) is v7 - say(UUID.v7().text_content) + say(UUID.v7().text) |
