They say that you cannot teach an old dog new tricks, so this dog has been up to some old tricks. A couple of days ago I released strftime[1] for javascript with partial support for all of PHP's strftime[2] format specifiers, and today I released version 1.2 with full support and the ability to localise it.
Get it via freshmeat here: http://freshmeat.net/projects/strftime-js/ (if you want the tarballs) or directly here: http://hacks.bluesmoon.info/strftime/ (if you only want the source and docs).
The code is BSD licensed.
Some more info: - The opengroup specification for strftime has 33 format specifiers and 19 modified format specifiers - PHP's strftime has the 33 basic format specifiers and adds 3 more - This javascript implementation supports the entire PHP set, and does not support the 19 modified format specifiers - The code supports locale specific representations through a locale extension mechanism which is well documented [3]
There are bound to be bugs, so send them my way any way you see fit. The project is also hosted on google code, but I'm not too happy with the interface and am considering moving it to sourceforge mainly for svn and issue tracking. If you have strong opinions one way or the other, let me know.
Anyway, for now, play with it, let me know about bugs, if you want to write a localised module for a particular language, feel free to do so and send it in.
Philip
[1] - http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html [2] - http://php.net/strftime [3] - http://hacks.bluesmoon.info/strftime/localisation.html
On Monday 28 Apr 2008, Philip Tellis wrote:
They say that you cannot teach an old dog new tricks, so this dog has been up to some old tricks. A couple of days ago I released strftime[1] for javascript with partial support for all of PHP's strftime[2] format specifiers, and today I released version 1.2 with full support and the ability to localise it.
Nice!
Some more info:
- The opengroup specification for strftime has 33 format specifiers
and 19 modified format specifiers
- PHP's strftime has the 33 basic format specifiers and adds 3 more
- This javascript implementation supports the entire PHP set, and
does not support the 19 modified format specifiers
Hmm, why not use the glibc strftime (or libc strftime) as the base model? That makes it more useful in more languages. I admit I haven't bothered to check the differences between the PHP and the libc strftime formats.
Regards,
-- Raju
2008/4/28 Raj Mathur raju@linux-delhi.org:
Some more info:
- The opengroup specification for strftime has 33 format specifiers
and 19 modified format specifiers
- PHP's strftime has the 33 basic format specifiers and adds 3 more
- This javascript implementation supports the entire PHP set, and
does not support the 19 modified format specifiers
Hmm, why not use the glibc strftime (or libc strftime) as the base model? That makes it more useful in more languages. I admit I haven't bothered to check the differences between the PHP and the libc strftime
I suppose you're right. Care to send in a patch? :P
The glibc version borrows from many standards, and supports 6 additional formats: %F, %k, %l, %P, %s and %+. This is in addition to the modified formats specified by opengroup. I could probably do these 6 formats, but someone else will have to put in the effort to do the 19 modified formats.
Also noticed that I need to make %p and %P easy to localise.