Skip to content

Commit

Permalink
readme formatting and improved deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonjs committed Mar 15, 2015
1 parent affbd8e commit f4a2c85
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
12 changes: 3 additions & 9 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,9 @@ e.g. `%q` becomes `q`. Use `%%` to get a literal `%` sign.
of UTC and a minus sign for those west of UTC, hours and minutes follow each
padded to 2 digits and with no delimiter between them

For more detail see `man 3 strftime` as the format specifiers should behave
identically. If behaviour differs please [file a bug](https://github.com/samsonjs/strftime/issues/new).

Any specifier can be modified with `-`, `_`, `0`, or `:` as well, as in Ruby.
Using `%-` will omit any leading zeroes or spaces, `%_` will force spaces
for padding instead of the default, and `%0` will force zeroes for padding.
There's some redundancy here as `%-d` and `%e` have the same result, but it
solves some awkwardness with formats like `%l`. Using `%:` for time zone offset,
as in `%:z` will insert a colon as a delimiter.
For more detail see `man 3 strftime` as the format specifiers should behave identically. If behaviour differs please [file a bug](https://github.com/samsonjs/strftime/issues/new).

Any specifier can be modified with `-`, `_`, `0`, or `:` as well, as in Ruby. Using `%-` will omit any leading zeroes or spaces, `%_` will force spaces for padding instead of the default, and `%0` will force zeroes for padding. There's some redundancy here as `%-d` and `%e` have the same result, but it solves some awkwardness with formats like `%l`. Using `%:` for time zone offset, as in `%:z` will insert a colon as a delimiter.

Contributors
============
Expand Down
12 changes: 6 additions & 6 deletions strftime.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
d = undefined;
}
if (locale) {
deprecationWarning("`" + _require + "(format, [date], [locale])`", _require + ".localize(locale)(format, [date])");
deprecationWarning("`" + _require + "(format, [date], [locale])`", "var s = " + _require + ".localize(locale); s(format, [date])");
}
var strftime = locale ? defaultStrftime.localize(locale) : defaultStrftime;
return strftime(fmt, d);
Expand All @@ -88,7 +88,7 @@
adaptForwards(deprecatedStrftime);
function deprecatedStrftime(fmt, d, locale) {
if (locale) {
deprecationWarning("`" + _require + ".strftime(format, [date], [locale])`", _require + ".localize(locale)(format, [date])");
deprecationWarning("`" + _require + ".strftime(format, [date], [locale])`", "var s = " + _require + ".localize(locale); s(format, [date])");
}
else {
deprecationWarning("`" + _require + ".strftime(format, [date])`", _require + "(format, [date])");
Expand All @@ -105,10 +105,10 @@
}

if (locale) {
deprecationWarning("`" + _require + ".strftimeTZ(format, date, locale, tz)`", _require + ".timezone(tz).localize(locale)(format, [date])");
deprecationWarning("`" + _require + ".strftimeTZ(format, date, locale, tz)`", "var s = " + _require + ".localize(locale).timezone(tz); s(format, [date])` or `var s = " + _require + ".localize(locale); s.timezone(tz)(format, [date])");
}
else {
deprecationWarning("`" + _require + ".strftimeTZ(format, date, tz)`", _require + ".timezone(tz)(format, [date])");
deprecationWarning("`" + _require + ".strftimeTZ(format, date, tz)`", "var s = " + _require + ".timezone(tz); s(format, [date])` or `" + _require + ".timezone(tz)(format, [date])");
}

var strftime = (locale ? defaultStrftime.localize(locale) : defaultStrftime).timezone(timezone);
Expand All @@ -118,10 +118,10 @@
var utcStrftime = defaultStrftime.utc();
function deprecatedStrftimeUTC(fmt, d, locale) {
if (locale) {
deprecationWarning("`" + _require + ".strftimeUTC(format, date, locale)`", _require + ".localize(locale).utc()(format, [date])");
deprecationWarning("`" + _require + ".strftimeUTC(format, date, locale)`", "var s = " + _require + ".localize(locale).utc(); s(format, [date])");
}
else {
deprecationWarning("`" + _require + ".strftimeUTC(format, [date])`", _require + ".utc()(format, [date])");
deprecationWarning("`" + _require + ".strftimeUTC(format, [date])`", "var s = " + _require + ".utc(); s(format, [date])");
}
var strftime = locale ? utcStrftime.localize(locale) : utcStrftime;
return strftime(fmt, d);
Expand Down

0 comments on commit f4a2c85

Please sign in to comment.