code style and copyright

This commit is contained in:
Sami Samhuri 2015-02-07 20:51:33 -08:00
parent 6bc6888fff
commit 603326eaed
2 changed files with 9 additions and 11 deletions

View file

@ -3,7 +3,7 @@
// github.com/samsonjs/strftime // github.com/samsonjs/strftime
// @_sjs // @_sjs
// //
// Copyright 2010 - 2013 Sami Samhuri <sami@samhuri.net> // Copyright 2010 - 2015 Sami Samhuri <sami@samhuri.net>
// //
// MIT License // MIT License
// http://sjs.mit-license.org // http://sjs.mit-license.org
@ -45,7 +45,7 @@
// Browsers and other environments // Browsers and other environments
else { else {
// Get the global object. Works in ES3, ES5, and ES5 strict mode. // 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 // Deprecated API, to be removed in v1.0
@ -71,18 +71,18 @@
} }
var strftime = (locale ? defaultStrftime.localize(locale) : defaultStrftime).timezone(timezone); var strftime = (locale ? defaultStrftime.localize(locale) : defaultStrftime).timezone(timezone);
return strftime(fmt, d); return strftime(fmt, d);
} };
namespace.strftimeUTC = function(fmt, d, locale) { namespace.strftimeUTC = function(fmt, d, locale) {
deprecationWarning("strftimeUTC", "require('strftime').utc()(format, date)` or `require('strftime').localize(locale).utc()(format, date)"); deprecationWarning("strftimeUTC", "require('strftime').utc()(format, date)` or `require('strftime').localize(locale).utc()(format, date)");
var strftime = (locale ? defaultStrftime.localize(locale) : defaultStrftime).utc(); var strftime = (locale ? defaultStrftime.localize(locale) : defaultStrftime).utc();
return strftime(fmt, d); return strftime(fmt, d);
} };
namespace.localizedStrftime = function(locale) { namespace.localizedStrftime = function(locale) {
deprecationWarning("localizedStrftime", "require('strftime').localize(locale)"); deprecationWarning("localizedStrftime", "require('strftime').localize(locale)");
return defaultStrftime.localize(locale); return defaultStrftime.localize(locale);
} };
// End of deprecated API // End of deprecated API
function Strftime(locale, customTimezoneOffset, useUtcTimezone) { function Strftime(locale, customTimezoneOffset, useUtcTimezone) {

View file

@ -18,9 +18,7 @@ assert.fn = function(value, msg) {
function assertFormat(time, format, expected, name, strftime) { function assertFormat(time, format, expected, name, strftime) {
var actual = strftime(format, time); var actual = strftime(format, time);
assert.equal(expected, actual, assert.equal(expected, actual, name + '("' + format + '", ' + time + ') is ' + JSON.stringify(actual) + ', expected ' + JSON.stringify(expected));
name + '("' + format + '", ' + time + ') is ' + JSON.stringify(actual)
+ ', expected ' + JSON.stringify(expected));
} }
assert.format = function(format, expected, expectedUTC, time) { assert.format = function(format, expected, expectedUTC, time) {
@ -114,7 +112,7 @@ assert.format('%Y', '2011');
assert.format('%y', '11'); assert.format('%y', '11');
assert.format('%Z', null, 'GMT'); assert.format('%Z', null, 'GMT');
assert.format('%z', null, '+0000'); assert.format('%z', null, '+0000');
assert.format('%%', '%') // any other char; assert.format('%%', '%'); // any other char
ok('GMT'); ok('GMT');
@ -145,8 +143,8 @@ var it_IT = {
var strftimeIT = strftime.localize(it_IT), var strftimeIT = strftime.localize(it_IT),
strftimeITUTC = strftimeIT.utc(); strftimeITUTC = strftimeIT.utc();
assert.format_it = function(format, expected, expectedUTC) { assert.format_it = function(format, expected, expectedUTC) {
if (expected) { assertFormat(Time, format, expected, 'strftime.localize(it_IT)', strftimeIT) } if (expected) { assertFormat(Time, format, expected, 'strftime.localize(it_IT)', strftimeIT); }
assertFormat(Time, format, expectedUTC || expected, 'strftime.localize(it_IT).utc()', strftimeITUTC) assertFormat(Time, format, expectedUTC || expected, 'strftime.localize(it_IT).utc()', strftimeITUTC);
}; };
assert.format_it('%A', 'martedi'); assert.format_it('%A', 'martedi');