runicjs
v1.0.0
Published
Stupid string to duration converter
Downloads
2
Maintainers
Readme
runic
Stupid string to duration converter
General usage
Two mods are available: using timeout and/or using exact time. It's not either-or, feel free to mix everything, even multiple times during the same command.
Order of timeouts, exact times and custom text is not important at all, you are free to specify the timer however you want to!
Quick example for the timeout:
"pause in 3 min"
Quick example for the exact time:
"I should leave at 6pm"
In the latter, it will calculate duration between your local "now" and specified exact time.
To Message, Or not to Message
The following timers are exactly the same, all three of them will return the same duration back.
"4 minutes"
"4m" # You have different methods to write the length (See below for more)
"remind me that I have a tea in the kitchen in 4 min"
Learn by Example
The simplest timer you can launch
"my first timer ever for 30 seconds"
This will simply return 30 seconds!
You can combine multiple durations
These durations might be of any length as long as it makes sense to you!
"1 minute 30s .5m 3600 seconds"
This will return an hour and 2 minutes!
Exact times can be used
Duration between current time and specified value will be calculated and added:
consider it is 8 am now (08:00)
"remind me to join the meeting call at 9:15"
This will return an hour and 15 minutes!
You can use -
in front of the duration
It will tell the timer that you want to move the target one hour towards your current time:
"2h -1h -30m"
This will return 30 minutes!
It works great when using with exact times
consider it is 4pm now (16:00)
"originally event starts at 6pm was moved 1 hour I need -2 hours to get there"
This will return an hour!
Timeout
Timer is a total of all specified timeouts combined. You can specify timeouts using keywords for hours, minutes and seconds.
Note that the space between the timeout and keyword is optional.
Hours
hours
hour
hrs
hr
h
E.g.
"10h"
"10 hr"
"10 hours"
Minutes
minutes
minute
mins
min
m
E.g.
"10m"
"10 min"
"10 minutes"
Seconds
seconds
second
secs
sec
s
E.g.
"10s"
"10 sec"
"10 seconds"
Floating numbers
You can use .
in your timeouts. For example, when you need to quickly specify
2 hours 30 minutes, but you don't want to write it down, you can do this:
"the long and boring way 2 hours 30 minutes"
"slightly shorter but still boring way 2h 30m"
"or in short 2.5h"
Or, possibly the shortest way to describe 30 minutes is:
".5h and it will be done"
Exact Time
Used to specify some time of interest explicitly. Under the hood it calculates the duration between the local now and local time and launches an ordinary timeout:
"should finish at 19:30"
"should finish at 7:30pm"
Just like with timeouts, the space between the time and "am"/"pm" is optional.
"at 1am"
"at 1 am"
Minutes part is optional and is going to be set to 0
by default, so
the following timers are equal:
"at 22"
"at 22:00"
"at 10pm"
"at 10:00 pm"
Where a day starts and ends?
In case specified time is in the past relative to the current 24h day, it carries out to the next day, for example:
Consider it is October 1st, 11:30pm (23:30)
"definitely go to sleep at 2am"
There already was point in time when 2am of October 1st occurred, so it carries out to the next day, October the 2nd, effectively setting your timer for 2 hours 30 minutes.
The same happens with more distant points in time, like this:
consider it is October 1st, 4:15pm (16:15)
"at 4:15am"