mirror of
https://github.com/samsonjs/strftime.git
synced 2026-03-25 09:05:48 +00:00
code style and copyright
This commit is contained in:
parent
6bc6888fff
commit
603326eaed
2 changed files with 9 additions and 11 deletions
10
strftime.js
10
strftime.js
|
|
@ -3,7 +3,7 @@
|
|||
// github.com/samsonjs/strftime
|
||||
// @_sjs
|
||||
//
|
||||
// Copyright 2010 - 2013 Sami Samhuri <sami@samhuri.net>
|
||||
// Copyright 2010 - 2015 Sami Samhuri <sami@samhuri.net>
|
||||
//
|
||||
// MIT License
|
||||
// http://sjs.mit-license.org
|
||||
|
|
@ -45,7 +45,7 @@
|
|||
// Browsers and other environments
|
||||
else {
|
||||
// Get the global object. Works in ES3, ES5, and ES5 strict mode.
|
||||
namespace = (function(){ return this || (1,eval)('this') }());
|
||||
namespace = (function(){ return this || (1,eval)('this'); }());
|
||||
}
|
||||
|
||||
// Deprecated API, to be removed in v1.0
|
||||
|
|
@ -71,18 +71,18 @@
|
|||
}
|
||||
var strftime = (locale ? defaultStrftime.localize(locale) : defaultStrftime).timezone(timezone);
|
||||
return strftime(fmt, d);
|
||||
}
|
||||
};
|
||||
|
||||
namespace.strftimeUTC = function(fmt, d, locale) {
|
||||
deprecationWarning("strftimeUTC", "require('strftime').utc()(format, date)` or `require('strftime').localize(locale).utc()(format, date)");
|
||||
var strftime = (locale ? defaultStrftime.localize(locale) : defaultStrftime).utc();
|
||||
return strftime(fmt, d);
|
||||
}
|
||||
};
|
||||
|
||||
namespace.localizedStrftime = function(locale) {
|
||||
deprecationWarning("localizedStrftime", "require('strftime').localize(locale)");
|
||||
return defaultStrftime.localize(locale);
|
||||
}
|
||||
};
|
||||
// End of deprecated API
|
||||
|
||||
function Strftime(locale, customTimezoneOffset, useUtcTimezone) {
|
||||
|
|
|
|||
10
test/test.js
10
test/test.js
|
|
@ -18,9 +18,7 @@ assert.fn = function(value, msg) {
|
|||
|
||||
function assertFormat(time, format, expected, name, strftime) {
|
||||
var actual = strftime(format, time);
|
||||
assert.equal(expected, actual,
|
||||
name + '("' + format + '", ' + time + ') is ' + JSON.stringify(actual)
|
||||
+ ', expected ' + JSON.stringify(expected));
|
||||
assert.equal(expected, actual, name + '("' + format + '", ' + time + ') is ' + JSON.stringify(actual) + ', expected ' + JSON.stringify(expected));
|
||||
}
|
||||
|
||||
assert.format = function(format, expected, expectedUTC, time) {
|
||||
|
|
@ -114,7 +112,7 @@ assert.format('%Y', '2011');
|
|||
assert.format('%y', '11');
|
||||
assert.format('%Z', null, 'GMT');
|
||||
assert.format('%z', null, '+0000');
|
||||
assert.format('%%', '%') // any other char;
|
||||
assert.format('%%', '%'); // any other char
|
||||
ok('GMT');
|
||||
|
||||
|
||||
|
|
@ -145,8 +143,8 @@ var it_IT = {
|
|||
var strftimeIT = strftime.localize(it_IT),
|
||||
strftimeITUTC = strftimeIT.utc();
|
||||
assert.format_it = function(format, expected, expectedUTC) {
|
||||
if (expected) { assertFormat(Time, format, expected, 'strftime.localize(it_IT)', strftimeIT) }
|
||||
assertFormat(Time, format, expectedUTC || expected, 'strftime.localize(it_IT).utc()', strftimeITUTC)
|
||||
if (expected) { assertFormat(Time, format, expected, 'strftime.localize(it_IT)', strftimeIT); }
|
||||
assertFormat(Time, format, expectedUTC || expected, 'strftime.localize(it_IT).utc()', strftimeITUTC);
|
||||
};
|
||||
|
||||
assert.format_it('%A', 'martedi');
|
||||
|
|
|
|||
Loading…
Reference in a new issue