irc-bot icon indicating copy to clipboard operation
irc-bot copied to clipboard

Add TimeParameter & RelativeTimeParameter

Open NanoSector opened this issue 7 years ago • 0 comments

Add a type of parameter which parses the given relative time (e.g. 1s, 4h, 5m, 6d, 7w...) or absolute time (18:05, etc.) and converts it to a set unit.

Syntax would be 'new RelativeTimeParameter('default time format (s/m/h/d/w/y)')' where the default time format is also the one to which the integer will be converted.

RelativeTimeParameter('m') with argument '1h' would return 60 (minutes) for example while TimeParameter('s') with 1h would be 3600 (seconds).

TimeParameter is different in that it can take a time format to convert to. E.g. TimeParameter('d-m-Y H:i') with 18:00 passed would assume 18:00 this day and thus return '22-05-2018 18:00'.

NanoSector avatar Jan 01 '18 16:01 NanoSector