Skip to content

Commit

Permalink
added tests and updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Cory Heslip committed Mar 5, 2015
1 parent 4de2693 commit 1222467
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Readme.md
Expand Up @@ -111,11 +111,12 @@ e.g. `%q` becomes `q`. Use `%%` to get a literal `%` sign.
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 `-`, `_`, or `0` as well, as in Ruby.
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`.
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
3 changes: 3 additions & 0 deletions test/test.js
Expand Up @@ -103,6 +103,7 @@ assert.format('%Y', '2011')
assert.format('%y', '11')
assert.format('%Z', null, 'GMT')
assert.format('%z', null, '+0000')
assert.format('%:z', null, '+00:00')
assert.format('%%', '%') // any other char
assert.format('%F %T', null, '1970-01-01 00:00:00', new Date(0))
ok('GMT')
Expand Down Expand Up @@ -175,6 +176,7 @@ assert.formatTZ('%F %r %z', '2011-06-07 08:51:45 PM +0200', '+0200')
assert.formatTZ('%F %r %z', '2011-06-07 11:51:45 AM -0700', -420)
assert.formatTZ('%F %r %z', '2011-06-07 11:51:45 AM -0700', '-0700')
assert.formatTZ('%F %r %z', '2011-06-07 11:21:45 AM -0730', '-0730')
assert.formatTZ('%F %r %:z', '2011-06-07 11:21:45 AM -07:30', '-0730')
ok('Time zone offset')


Expand Down Expand Up @@ -221,5 +223,6 @@ function testTimezone(regex) {
assert.format('%T', T, '18:51:45')
assert.format('%Z', tz, 'GMT')
assert.format('%z', sign + '0' + Math.abs(hourDiff) + '00', '+0000')
assert.format('%:z', sign + '0' + Math.abs(hourDiff) + ':00', '+00:00')
}
}

0 comments on commit 1222467

Please sign in to comment.