-
-
Notifications
You must be signed in to change notification settings - Fork 0
wrapper_bash
mozrin edited this page Dec 14, 2025
·
1 revision
A simple CLI utility and Bash library for the Universal Timestamp Library.
The Bash wrapper consists of:
-
uts-cli: A C binary that links against the library and provides a CLI interface. -
universal_timestamp.sh: A shell script library that wrapsuts-cliwith convenient shell functions.
make build_bash
sudo make install_bashThis installs:
/usr/local/bin/uts-cli/usr/local/bin/universal_timestamp.sh
You can use the CLI tool directly:
uts-cli now
# Output: 2024-12-14T12:00:00.123456789Z
uts-cli now-nanos
# Output: 1702555200123456789
uts-cli parse "2024-01-01T00:00:00Z"
# Output: 1704067200000000000Source the library in your scripts:
#!/bin/bash
source /usr/local/bin/universal_timestamp.sh
# Get current time
ts=$(ut_now)
echo "Current time: $ts"
# Get nanoseconds
nanos=$(ut_now_nanos)
# Arithmetic (using bc or shell math)
future_nanos=$((nanos + 1000000000)) # +1 second
# Format back to string
future_ts=$(ut_format "$future_nanos")
echo "One second later: $future_ts"| Function | CLI Command | Description |
|---|---|---|
ut_now |
uts-cli now |
Get current ISO-8601 timestamp |
ut_now_nanos |
uts-cli now-nanos |
Get current Unix nanoseconds |
ut_parse <str> |
uts-cli parse |
Parse ISO-8601 string to nanos |
ut_format <nanos> |
uts-cli format |
Format nanos to ISO-8601 string |
make test_bash© 2025 Moztopia. Portions of this code and documentation are copyrighted.
All Rights Reserved.