About this entry
You’re currently reading “Yet Another Pretty Date JavaScript,” an entry on Web 3.0, 6 Bladed Razors, 7 Minute Abs
- Published:
- 03.23.08 / 8pm
- Category:
- JavaScript, Projects
Bookmark with- del.icio.us
Add to- Digg
Post on
Search on - Technorati
Yet Another Pretty Date JavaScript
I can't let this Pretty Date thing go. I decided to use a modification of John Resig's Pretty Date JavaScript implementation written by Dean Landolt and shared in the comments on John's page. The script was an obvious choice for the next iteration of Alarmd, which is nearing completion as I type.
The more I used Dean Landolt's script, the more problems I began to see with his implementation. It was a good start, but definitely had bugs. His assumptions translating from integer second differences to human readable labels stretched too far at times (there is an error in logic to say anything between 24 hours and 48 hours from now can be labeled "Tomorrow"), and he was a bit loose with his difference categories (assumed average month length was 28 days, and always used Math.floor instead of rounding -- 47 hours from now would be labeled "1 Day"). It was great code otherwise, and I definitely liked the way he used the while loop to run through the comparisons.
So, I've cleaned up his great start, and am releasing it to the world in the spirit of cooperation and open sauce. You just read that typo out loud didn't you?
Download: Yet Another Pretty Date Implementation (2 KB)
Technorati Tags: JavaScript
subscribe to my blog. You'll save me some bandwidth that way.

Follow
25 Comments
Jump to comment form | comments rss [?] | trackback uri [?]