Extjs Form Field: Parse Hours using format like '3d 4h'?

222 Views Asked by At

I would like to have a textfield, representing the amount of time of something, parse a text value like '3d 4h' into hours. The example I provide would be 3 days, 4 hours -- 76 hours.

Before I go off and roll my own text-to-number parser engine, has anyone done something like this before, or does Extj4 provide a way to ease this process?

Thanks!

1

There are 1 best solutions below

0
On

I haven't seen this in JS.

You might get some inspiration looking at the source code for PHP's strtotime function, which does essentially what you are looking for:

https://github.com/php/php-src/blob/master/ext/date/php_date.c#L1324

Other options:

regex for textual dates? (aka source code for php's strtotime )