Sha256: ad89a2beca8f9ec865e5f99ae56ddcc11f1fd19e9bd86bfd80980bb30b9fc4b5

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

module "strftime"

momentMap =
  "%a": "ddd"
  "%A": "dddd"
  "%b": "MMM"
  "%B": "MMMM"
  "%c": "toString()"
  "%d": "DD"
  "%e": "D"
  "%H": "HH"
  "%I": "hh"
  "%l": "h"
  "%m": "MM"
  "%M": "mm"
  "%p": "A"
  "%P": "a"
  "%S": "ss"
  "%w": "e"
  "%y": "YY"
  "%Y": "YYYY"

for day in [0..30] by 6
  do (day) ->
    for hour in [0..24] by 6
      do (hour) ->

        for format, momentFormat of momentMap
          do (format, momentFormat) ->
            test "#{format} (+#{day} days, #{hour} hours)", ->
              now = moment().add("days", day).add("hours", hour)
              el  = addTimeEl {format, datetime: now.toISOString()}
              run()

              equal getText(el),
                if func = momentFormat.match(/(\w+)\(\)/)?[1]
                  now.toDate()[func]()
                else
                  now.format momentFormat

        test "%Z Timezone (+#{day} days, #{hour} hours)", ->
          now = moment().add("days", day).add("hours", hour)
          el  = addTimeEl format: "%Z", datetime: now.toISOString()
          run()

          text = getText el
          ok /^\w{3,4}$/.test(text), "#{text} doesn't look like a timezone"

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
local_time-1.0.2 test/javascripts/local_time/strftime_test.js.coffee
local_time-1.0.1 test/javascripts/local_time/strftime_test.js.coffee
local_time-1.0.0 test/javascripts/local_time/strftime_test.js.coffee