FAQ

Usage

Is there a manual on how to use this library?

Yes, see Example usage

Where can I get a minified version of this library?

The minified version is available here.

Which format specifiers are supported?

See Format specifiers

Why?

Why this library?

I've used the strftime function in C, PHP and the Unix shell, and found it very useful to do date formatting. When I needed to do date formatting in javascript, I decided that it made the most sense to just reuse what I'm already familiar with.

Why another strftime implementation for Javascript?

Yes, there are other strftime implementations for Javascript, but I saw problems with all of them that meant I couldn't use them directly. Some implementations had bad designs. For example, iterating through all possible specifiers and scanning the string for them. Others were tied to specific libraries like prototype.

Trying to extend any of the existing implementations would have required only slightly less effort than writing this from scratch. In the end it took me just about 3 hours to write the code and about 6 hours battling with doxygen to write these docs.

I also had an idea of how I wanted to implement this, so decided to try it.

Why extend the Date class rather than subclass it?

I tried subclassing Date and failed. I didn't want to waste time on figuring out if there was a problem in my code or if it just wasn't possible. Adding to the Date.prototype worked well, so I stuck with it.

I did have some worries because of the way for..in loops got messed up after json.js added to the Object.prototype, but that isn't an issue here since {} is not a subclass of Date.

My last doubt was about the Date.ext namespace that I created. I still don't like this, but I felt that ext at least makes clear that this is external or an extension.

It's quite possible that some future version of javascript will add an ext or a locale or a strftime property/method to the Date class, but this library should probably check for capabilities before doing what it does.

Curiosity

How big is the code?

How long did it take to write this?

15 minutes for the idea while I was composing this blog post: http://tech.bluesmoon.info/2008/04/javascript-date-functions.html

3 hours in one evening to write v1.0 of the code and 6 hours the same night to write the docs and this manual. As you can tell, I'm fairly sleepy.

Versions 1.1 and 1.2 were done in a couple of hours each, and version 1.3 in under one hour.

Contributing

How can I request features or make suggestions?

You can leave a comment on my blog post about this library here: http://tech.bluesmoon.info/2008/04/strftime-in-javascript.html

Can I/How can I contribute code to this library?

Yes, that would be very nice, thank you. You can do various things. You can make changes to the library, and make a diff against the current file and mail me that diff at philip@bluesmoon.info, or you could just host the new file on your own servers and add your name to the copyright list at the top stating which parts you've added.

If you do mail me a diff, let me know how you'd like to be listed in the copyright section.

Who owns the copyright on contributed code?

The contributor retains copyright on contributed code.

In some cases I may use contributed code as a template and write the code myself. In this case I'll give the contributor credit for the idea, but will not add their name to the copyright holders list.


Generated on Tue Jun 17 22:31:26 2008 for strftime by  doxygen 1.5.5