As I was working on a new Greasemonkey script today, I needed a way to parse 
the date from a string, and format it into DD-MM-YYYY. Parsing the date 
turned out to be easy:

https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference:Global_Objects:Date#Methods

However, now I wanted to find a way to format it. I landed on this post:

http://blog.stevenlevithan.com/archives/date-time-format

As it turns out, JavaScript has no built-in method equivalent to strftime(), 
and this post supplies an alternative. So I thought to myself: no problem - 
I'll just use sprintf. But, lo and behold - no sprintf for us:

http://www.google.com/search?q=javascript%20sprintf

So I bit the bullet and copy-and-pasted the date-time-format code into my 
script. The format supported by it is not strftime()-compatible, but rather 
something like ColdFusion. And the script now works.

But I'm really surprised that JavaScript doesn't even have something like 
sprintf. That's really lame.

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
"Humanity" - Parody of Modern Life - http://xrl.us/bkeut

Shlomi, so what are you working on? Working on a new wiki about unit testing 
fortunes in freecell? -- Ran Eilam
_______________________________________________
Perl mailing list
[email protected]
http://perl.org.il/mailman/listinfo/perl

Reply via email to