Skip to content

Commit

Permalink
Merge pull request #3 from fresk-nc/master
Browse files Browse the repository at this point in the history
strftime больше не перезаписывает переданную ей дату
  • Loading branch information
Anton committed Nov 26, 2015
2 parents 674cd1e + 2804e34 commit da22045
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 22 deletions.
16 changes: 9 additions & 7 deletions lib/strftime.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,23 @@
*/
/*jshint -W079 */
var strftime = function(format, date, utc, localeName) {
if (typeof date === 'undefined') {
date = new Date();
var newDate = date;

if (typeof newDate === 'undefined') {
newDate = new Date();
}

if (typeof date === 'number') {
date = new Date(date);
if (typeof newDate === 'number') {
newDate = new Date(newDate);
}

if (!(date instanceof Date) || String(date) === 'Invalid Date') {
if (!(newDate instanceof Date) || String(newDate) === 'Invalid Date') {
return null;
}

if (utc) {
date.setTime(date.getTime() + date.getTimezoneOffset() * 60000);
newDate = new Date(newDate.getTime() + newDate.getTimezoneOffset() * 60000);
}

return strftime.format(format, date, localeName);
return strftime.format(format, newDate, localeName);
};
16 changes: 9 additions & 7 deletions strftime.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,25 @@
*/
/*jshint -W079 */
var strftime = function(format, date, utc, localeName) {
if (typeof date === 'undefined') {
date = new Date();
var newDate = date;

if (typeof newDate === 'undefined') {
newDate = new Date();
}

if (typeof date === 'number') {
date = new Date(date);
if (typeof newDate === 'number') {
newDate = new Date(newDate);
}

if (!(date instanceof Date) || String(date) === 'Invalid Date') {
if (!(newDate instanceof Date) || String(newDate) === 'Invalid Date') {
return null;
}

if (utc) {
date.setTime(date.getTime() + date.getTimezoneOffset() * 60000);
newDate = new Date(newDate.getTime() + newDate.getTimezoneOffset() * 60000);
}

return strftime.format(format, date, localeName);
return strftime.format(format, newDate, localeName);
};


Expand Down
16 changes: 9 additions & 7 deletions strftime.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,25 @@
*/
/*jshint -W079 */
var strftime = function(format, date, utc, localeName) {
if (typeof date === 'undefined') {
date = new Date();
var newDate = date;

if (typeof newDate === 'undefined') {
newDate = new Date();
}

if (typeof date === 'number') {
date = new Date(date);
if (typeof newDate === 'number') {
newDate = new Date(newDate);
}

if (!(date instanceof Date) || String(date) === 'Invalid Date') {
if (!(newDate instanceof Date) || String(newDate) === 'Invalid Date') {
return null;
}

if (utc) {
date.setTime(date.getTime() + date.getTimezoneOffset() * 60000);
newDate = new Date(newDate.getTime() + newDate.getTimezoneOffset() * 60000);
}

return strftime.format(format, date, localeName);
return strftime.format(format, newDate, localeName);
};


Expand Down
2 changes: 1 addition & 1 deletion strftime.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit da22045

Please sign in to comment.