Module core/date
Adds useful methods to the JavaScript Date type.
Class Date
Instance Methods
- diff(dateObj)
- equals(Object, Int)
- format(String, Object, Object)
- getAge(param)
- getExpiry(param)
- getTimespan(Object)
- toLocalTime()
- toUtc()
Date.prototype.diff (dateObj)
returns the difference between this and another date object in milliseconds
Parameters
| dateObj |
Date.prototype.equals (Object, Int)
checks if a date object equals another date object
Parameters
| Object | Date object to compare | |
| Int | indicating how far the comparison should go |
Returns
| Boolean |
Date.prototype.format (String, Object, Object)
Format a Date to a string. For details on the format pattern, see http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html
Parameters
| String | Format pattern | |
| Object | Java Locale Object (optional) | |
| Object | Java TimeZone Object (optional) |
Returns
| String formatted Date |
Date.prototype.getAge (param)
return the past timespan between this Date object and the current Date or a different Date object
Parameters
| param |
Date.prototype.getExpiry (param)
return the future timespan between this Date object and the current Date or a different Date object
Parameters
| param |
Date.prototype.getTimespan (Object)
return the timespan to current date/time or a different Date object
Parameters
| Object | parameter object containing optional properties: .now = String to use if difference is < 1 minute .day|days = String to use for single|multiple day(s) .hour|hours = String to use for single|multiple hour(s) .minute|minutes = String to use for single|multiple minute(s) .date = Date object to use for calculating the timespan |
Returns
| Object containing properties: .isFuture = (Boolean) .span = (String) timespan |
Date.prototype.toLocalTime ()
set the date/time to local time by adding the timezone offset
Date.prototype.toUtc ()
set the date/time to UTC by subtracting the timezone offset
