Go to the source code of this file.
Variables | |
Date | ext = {} |
Date extension object - all supporting objects go in here. | |
Date ext | util = {} |
Utility methods. | |
Date ext util | xPad |
Left pad a number with something. | |
Date prototype | locale = 'en-GB' |
Currently selected locale. | |
Date ext | locales = { } |
Localised strings for days of the week and months of the year. | |
Date ext locales | en |
Localised strings for English (British). | |
Date ext | formats |
List of supported format specifiers. | |
Date ext | aggregates |
List of aggregate format specifiers. | |
Date ext | unsupported = { } |
Date prototype | strftime |
Formats the date according to the specified format. |
List of supported format specifiers.
%a, %A, %b and %B should be localised for non-English locales.
var d = new Date(); var ymd = d.strftime('%Y/%m/%d'); var iso = d.strftime('%Y-%m-%dT%H:%M:%S%z');
Date.ext.locales for localisation information
http://www.php.net/strftime for the PHP implementation which is the basis for this
http://tech.bluesmoon.info/2008/04/strftime-in-javascript.html for feedback
Definition in file strftime.js.
Date ext aggregates |
Initial value:
{ c: 'locale', D: '%m/%d/%y', h: '%b', n: '\n', r: '%I:%M:%S %p', R: '%H:%M', t: '\t', T: '%H:%M:%S', x: 'locale', X: 'locale' }
Aggregate format specifiers map to a combination of basic format specifiers. These are implemented in terms of Date.ext.formats.
A format specifier that maps to 'locale' is read from Date.ext.locales[current-locale].
Definition at line 299 of file strftime.js.
Initial value:
{ a: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], A: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], b: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], B: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], c: '%a %d %b %Y %T %Z', p: ['AM', 'PM'], P: ['am', 'pm'], x: '%d/%m/%y', X: '%T' }
This will be used for any of the English dialects unless overridden by a country specific one. This is the default locale if none specified
Definition at line 136 of file strftime.js.
List of supported format specifiers.
Definition at line 207 of file strftime.js.
Currently selected locale.
The locale for a specific date object may be changed using
Date.locale = "new-locale";
Definition at line 96 of file strftime.js.
Localised strings for days of the week and months of the year.
To create your own local strings, add a locale object to the locales object. The key of your object should be the same as your locale name. For example: en-US, fr, fr-CH, de-DE Names are case sensitive and are described at http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes Your locale object must contain the following keys:
a | Short names of days of week starting with Sunday | |
A | Long names days of week starting with Sunday | |
b | Short names of months of the year starting with January | |
B | Long names of months of the year starting with February | |
c | The preferred date and time representation in your locale | |
p | AM or PM in your locale | |
P | am or pm in your locale | |
x | The preferred date representation for the current locale without the time. | |
X | The preferred time representation for the current locale without the date. |
Localisation for detailed documentation on localising strftime for your own locale
Definition at line 128 of file strftime.js.
Date prototype strftime |
Formats the date according to the specified format.
fmt | The format to format the date in. This may be a combination of the following: List of supported format specifiers.
|
Definition at line 335 of file strftime.js.
Date ext unsupported = { } |
List of unsupported format specifiers.
All format specifiers supported by the PHP implementation are supported by this javascript implementation.
Definition at line 324 of file strftime.js.
Initial value:
function(x, pad, r) { if(typeof(r) == 'undefined') { r=10; } for( ; parseInt(x, 10)<r && r>1; r/=10) x = pad.toString() + x; return x.toString(); }
Takes a number and pads it to the left with the passed in pad character
x | The number to pad | |
pad | The string to pad with | |
r | [optional] Upper limit for pad. A value of 10 pads to 2 digits, a value of 100 pads to 3 digits. Default is 10. |
Definition at line 79 of file strftime.js.