mirror of
https://github.com/RGBCube/bonfire.v
synced 2025-07-28 14:37:44 +00:00
Fix examples
This commit is contained in:
parent
8de1cb17d7
commit
2ff93821b7
2 changed files with 33 additions and 33 deletions
|
@ -1,30 +1,17 @@
|
||||||
module main
|
module main
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import rgbcube.bonfire { Snowflake, TimeFormat }
|
import rgbcube.bonfire { Snowflake }
|
||||||
|
|
||||||
[noreturn]
|
|
||||||
fn print_help_and_exit1() {
|
|
||||||
println('Usage: <format> <id>')
|
|
||||||
println('Format can be either short_time, long_time, short_date, long_date, short_date_time, long_date_time or relative')
|
|
||||||
exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
snowflake := Snowflake(os.args[2].i64() or { print_help_and_exit1() })
|
snowflake := Snowflake(os.args[1] or {
|
||||||
|
println('Usage: <id>')
|
||||||
|
exit(1)
|
||||||
|
}.i64())
|
||||||
|
|
||||||
format_str := os.args[1]
|
println('Snowflake: ${snowflake}')
|
||||||
|
println('- Created at: ${snowflake.created_at()}')
|
||||||
format := match format_str {
|
println('- Worker ID: ${snowflake.worker_id()}')
|
||||||
'short_time' { TimeFormat.short_time }
|
println('- Process ID: ${snowflake.process_id()}')
|
||||||
'long_time' { TimeFormat.long_time }
|
println('- Sequence number: ${snowflake.sequence_number()}')
|
||||||
'short_date' { TimeFormat.short_date }
|
|
||||||
'long_date' { TimeFormat.long_date }
|
|
||||||
'short_date_time' { TimeFormat.short_date_time }
|
|
||||||
'long_date_time' { TimeFormat.long_date_time }
|
|
||||||
'relative' { TimeFormat.relative }
|
|
||||||
else { print_help_and_exit1() }
|
|
||||||
}
|
|
||||||
|
|
||||||
println(snowflake.format(format))
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,30 @@
|
||||||
module main
|
module main
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import rgbcube.bonfire { Snowflake }
|
import rgbcube.bonfire { Snowflake, TimeFormat }
|
||||||
|
|
||||||
|
[noreturn]
|
||||||
|
fn print_help_and_exit1() {
|
||||||
|
println('Usage: <format> <id>')
|
||||||
|
println('Format can be either short_time, long_time, short_date, long_date, short_date_time, long_date_time or relative')
|
||||||
|
exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
snowflake := Snowflake(os.args[1] or {
|
time := Snowflake(os.args[2] or { print_help_and_exit1() }.i64()).created_at()
|
||||||
println('Usage: <id>')
|
|
||||||
exit(1)
|
|
||||||
})
|
|
||||||
|
|
||||||
println('Snowflake: ${snowflake}')
|
format_str := os.args[1]
|
||||||
println('- Created at: ${snowflake.created_at()}')
|
|
||||||
println('- Worker ID: ${snowflake.worker_id()}')
|
format := match format_str {
|
||||||
println('- Process ID: ${snowflake.process_id()}')
|
'short_time' { TimeFormat.short_time }
|
||||||
println('- Sequence number: ${snowflake.sequence_number()}')
|
'long_time' { TimeFormat.long_time }
|
||||||
|
'short_date' { TimeFormat.short_date }
|
||||||
|
'long_date' { TimeFormat.long_date }
|
||||||
|
'short_date_time' { TimeFormat.short_date_time }
|
||||||
|
'long_date_time' { TimeFormat.long_date_time }
|
||||||
|
'relative' { TimeFormat.relative }
|
||||||
|
else { print_help_and_exit1() }
|
||||||
|
}
|
||||||
|
|
||||||
|
println(time.format(format))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue