Created
December 1, 2011 22:48
-
-
Save caillou/1420463 to your computer and use it in GitHub Desktop.
Possible addition to moment.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// We assume it's Friday, December 2nd, 2 PM | |
// This could be interesting for a listing of events in a calendar. | |
// Two Questions: | |
// 1. How would you call the function? | |
// 2. What would you return for the dates in 1 and 2 weeks? | |
moment().xxx() // "Today at 2 PM" | |
moment().add('hours', 1).xxx() // "Today at 3 PM" | |
moment().add('days', 1).xxx() // "Tomorrow at 2 PM" | |
moment().add('days', 2).xxx() // "Sunday at 2 PM" | |
moment().add('weeks', 1).xxx() // What do you think ??? | |
moment().add('weeks', 2).xxx() // 12/16/2011 What do you think ??? | |
moment().subtract('hours', 1).xxx() // "Today at 1 PM" | |
moment().subtract('days', 1).xxx() // "Yesterday at 2 PM" | |
moment().subtract('days', 2).xxx() // "Wednesday at 2 PM" | |
moment().subtract('weeks', 1).xxx() // What do you think ??? | |
moment().subtract('weeks', 2).xxx() // 11/18/2011 What do you think ??? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm thinking of adding something similar as well. Couldn't think of a name though either...
https://gist.github.com/1280098