local-time.js now supports custom time formats. idea by copypaste
This commit is contained in:
parent
2a546e5b2d
commit
63b9c4db5f
@ -8,6 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Usage:
|
* Usage:
|
||||||
* // $config['additional_javascript'][] = 'js/jquery.min.js';
|
* // $config['additional_javascript'][] = 'js/jquery.min.js';
|
||||||
|
* // $config['additional_javascript'][] = 'js/strftime.min.js';
|
||||||
* $config['additional_javascript'][] = 'js/local-time.js';
|
* $config['additional_javascript'][] = 'js/local-time.js';
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -24,6 +25,27 @@ onready(function(){
|
|||||||
return [Math.pow(10, count - num.toString().length), num].join('').substr(1);
|
return [Math.pow(10, count - num.toString().length), num].join('').substr(1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var datelocale =
|
||||||
|
{ days: [_('Sunday'), _('Monday'), _('Tuesday'), _('Wednesday'), _('Thursday'), _('Friday'), _('Saturday')]
|
||||||
|
, shortDays: [_("Sun"), _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat")]
|
||||||
|
, months: [_('January'), _('February'), _('March'), _('April'), _('May'), _('June'), _('July'), _('August'), _('September'), _('October'), _('November'), _('December')]
|
||||||
|
, shortMonths: [_('Jan'), _('Feb'), _('Mar'), _('Apr'), _('May'), _('Jun'), _('Jul'), _('Aug'), _('Sep'), _('Oct'), _('Nov'), _('Dec')]
|
||||||
|
, AM: _('AM')
|
||||||
|
, PM: _('PM')
|
||||||
|
, am: _('am')
|
||||||
|
, pm: _('pm')
|
||||||
|
};
|
||||||
|
var dateformat = (typeof strftime === 'undefined') ? function(t) {
|
||||||
|
return zeropad(t.getMonth() + 1, 2) + "/" + zeropad(t.getDate(), 2) + "/" + t.getFullYear().toString().substring(2) +
|
||||||
|
" (" + [_("Sun"), _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun")][t.getDay()] + ") " +
|
||||||
|
// time
|
||||||
|
zeropad(t.getHours(), 2) + ":" + zeropad(t.getMinutes(), 2) + ":" + zeropad(t.getSeconds(), 2);
|
||||||
|
|
||||||
|
} : function(t) {
|
||||||
|
// post_date is defined in templates/main.js
|
||||||
|
return strftime(window.post_date, t, datelocale);
|
||||||
|
};
|
||||||
|
|
||||||
var do_localtime = function(elem) {
|
var do_localtime = function(elem) {
|
||||||
var times = elem.getElementsByTagName('time');
|
var times = elem.getElementsByTagName('time');
|
||||||
|
|
||||||
@ -35,12 +57,7 @@ onready(function(){
|
|||||||
|
|
||||||
|
|
||||||
times[i].setAttribute('data-local', 'true');
|
times[i].setAttribute('data-local', 'true');
|
||||||
times[i].innerHTML =
|
times[i].innerHTML = dateformat(t);
|
||||||
// date
|
|
||||||
zeropad(t.getMonth() + 1, 2) + "/" + zeropad(t.getDate(), 2) + "/" + t.getFullYear().toString().substring(2) +
|
|
||||||
" (" + [_("Sun"), _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun")][t.getDay()] + ") " +
|
|
||||||
// time
|
|
||||||
zeropad(t.getHours(), 2) + ":" + zeropad(t.getMinutes(), 2) + ":" + zeropad(t.getSeconds(), 2);
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -288,10 +288,12 @@ function ready() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onready(init);
|
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
|
||||||
|
var post_date = "{{ config.post_date }}";
|
||||||
|
|
||||||
|
onready(init);
|
||||||
|
|
||||||
{% if config.google_analytics %}{% raw %}
|
{% if config.google_analytics %}{% raw %}
|
||||||
|
|
||||||
var _gaq = _gaq || [];_gaq.push(['_setAccount', '{% endraw %}{{ config.google_analytics }}{% raw %}']);{% endraw %}{% if config.google_analytics_domain %}{% raw %}_gaq.push(['_setDomainName', '{% endraw %}{{ config.google_analytics_domain }}{% raw %}']){% endraw %}{% endif %}{% if not config.google_analytics_domain %}{% raw %}_gaq.push(['_setDomainName', 'none']){% endraw %}{% endif %}{% raw %};_gaq.push(['_trackPageview']);(function() {var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);})();{% endraw %}{% endif %}
|
var _gaq = _gaq || [];_gaq.push(['_setAccount', '{% endraw %}{{ config.google_analytics }}{% raw %}']);{% endraw %}{% if config.google_analytics_domain %}{% raw %}_gaq.push(['_setDomainName', '{% endraw %}{{ config.google_analytics_domain }}{% raw %}']){% endraw %}{% endif %}{% if not config.google_analytics_domain %}{% raw %}_gaq.push(['_setDomainName', 'none']){% endraw %}{% endif %}{% raw %};_gaq.push(['_trackPageview']);(function() {var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);})();{% endraw %}{% endif %}
|
||||||
|
Loading…
Reference in New Issue
Block a user