It is a plugin to make dates more human readable. 12.12.2012 15:30 will become relative to 3 days ago. It supports i18n, currently english and sloven languages are supported. In the i18n folder is the demo for sloven language, so you can use the same schema to add another language.
The config options:
Option | Default setting | Usage |
---|---|---|
nowDateObject | new Date() | The current date object |
makeTimestamp | function | the function which takes text and return a JS Date object. |
pattern | /([0-3]?[0-9]).([0|1]?[0-9]).(\d{4})\s?(\d{2})?:?(\d{2})?$/ | How to parse the date |
patternOrder | [ 3, 2, 1, 4, 5 ] | Date object parameters order |
dayOnly | false | If true, minutes or hours wont be shown. 20 minutes after will become today |
hoverShow | true | If true on hover the original date will be shown |
autoUpdateInterval | 60000 | Interval in milliseconds to update text. If 0 no update will be done. |
monthMessages | ... | See i18n |
dayMessages | ... | See i18n |
hourMessages | ... | See i18n |
minMessages | ... | See i18n |
The standart usage would be:
$('.date').niceDate();
$('.date').niceDate({autoUpdateInterval: 0}); // no auto update
To manually update the text you can use the data object:
$('.date).each(function(){
$(this).data('plugin_niceDate').update();
});
To be written.
- v0.2 Added auto update. Rewritten the whole plugin after jquery plugin boilerplate. Added manual update function.
- v0.1 Freshly created
Demo available on http://maraz.org/demo/jquery-niceDate/ or the index.html file.