This commit is contained in:
Itay Komemy 2014-04-17 12:48:22 +00:00
commit 126499d618

View file

@ -15,7 +15,7 @@
var namespace; var namespace;
// CommonJS / Node module // CommonJS / Node module
if (typeof module !== 'undefined') { if (typeof module != 'undefined') {
namespace = module.exports = strftime; namespace = module.exports = strftime;
} }
@ -46,7 +46,7 @@
// locale is optional // locale is optional
namespace.strftimeTZ = strftime.strftimeTZ = strftimeTZ; namespace.strftimeTZ = strftime.strftimeTZ = strftimeTZ;
function strftimeTZ(fmt, d, locale, timezone) { function strftimeTZ(fmt, d, locale, timezone) {
if ((typeof locale == 'number' || typeof locale == 'string') && timezone == null) { if ((typeof locale === 'number' || typeof locale === 'string') && timezone == null) {
timezone = locale; timezone = locale;
locale = undefined; locale = undefined;
} }
@ -91,7 +91,7 @@
var tz = options.timezone; var tz = options.timezone;
var tzType = typeof tz; var tzType = typeof tz;
if (options.utc || tzType == 'number' || tzType == 'string') { if (options.utc || tzType === 'number' || tzType === 'string') {
d = dateToUTC(d); d = dateToUTC(d);
} }
@ -99,8 +99,8 @@
// ISO 8601 format timezone string, [-+]HHMM // ISO 8601 format timezone string, [-+]HHMM
// //
// Convert to the number of minutes and it'll be applied to the date below. // Convert to the number of minutes and it'll be applied to the date below.
if (tzType == 'string') { if (tzType === 'string') {
var sign = tz[0] == '-' ? -1 : 1; var sign = tz[0] === '-' ? -1 : 1;
var hours = parseInt(tz.slice(1, 3), 10); var hours = parseInt(tz.slice(1, 3), 10);
var mins = parseInt(tz.slice(3, 5), 10); var mins = parseInt(tz.slice(3, 5), 10);
tz = sign * (60 * hours) + mins; tz = sign * (60 * hours) + mins;
@ -117,18 +117,18 @@
return fmt.replace(/%([-_0]?.)/g, function(_, c) { return fmt.replace(/%([-_0]?.)/g, function(_, c) {
var mod, padding; var mod, padding;
if (c.length == 2) { if (c.length === 2) {
mod = c[0]; mod = c[0];
// omit padding // omit padding
if (mod == '-') { if (mod === '-') {
padding = ''; padding = '';
} }
// pad with space // pad with space
else if (mod == '_') { else if (mod === '_') {
padding = ' '; padding = ' ';
} }
// pad with zero // pad with zero
else if (mod == '0') { else if (mod === '0') {
padding = '0'; padding = '0';
} }
else { else {
@ -235,7 +235,7 @@
// '4' // '4'
case 'u': case 'u':
var day = d.getDay(); var day = d.getDay();
return day == 0 ? 7 : day; // 1 - 7, Monday is first day of the week return day === 0 ? 7 : day; // 1 - 7, Monday is first day of the week
// '1-Jan-1970' // '1-Jan-1970'
case 'v': return _strftime(locale.formats.v || '%e-%b-%Y', d, locale); case 'v': return _strftime(locale.formats.v || '%e-%b-%Y', d, locale);
@ -270,7 +270,7 @@
return "+0000"; return "+0000";
} }
else { else {
var off = typeof tz == 'number' ? tz : -d.getTimezoneOffset(); var off = typeof tz === 'number' ? tz : -d.getTimezoneOffset();
return (off < 0 ? '-' : '+') + pad(Math.abs(off / 60)) + pad(off % 60); return (off < 0 ? '-' : '+') + pad(Math.abs(off / 60)) + pad(off % 60);
} }
@ -290,7 +290,7 @@
, n = RequiredDateMethods.length , n = RequiredDateMethods.length
; ;
for (i = 0; i < n; ++i) { for (i = 0; i < n; ++i) {
if (typeof x[RequiredDateMethods[i]] != 'function') { if (typeof x[RequiredDateMethods[i]] !== 'function') {
return false; return false;
} }
} }
@ -321,7 +321,7 @@
function hours12(d) { function hours12(d) {
var hour = d.getHours(); var hour = d.getHours();
if (hour == 0) hour = 12; if (hour === 0) hour = 12;
else if (hour > 12) hour -= 12; else if (hour > 12) hour -= 12;
return hour; return hour;
} }
@ -350,8 +350,8 @@
// This works by shifting the weekday back by one day if we // This works by shifting the weekday back by one day if we
// are treating Monday as the first day of the week. // are treating Monday as the first day of the week.
var wday = d.getDay(); var wday = d.getDay();
if (firstWeekday == 'monday') { if (firstWeekday === 'monday') {
if (wday == 0) // Sunday if (wday === 0) // Sunday
wday = 6; wday = 6;
else else
wday--; wday--;