Exemplo n.º 1
0
test('moment can change locales with multiple arity', () => {
  tz.changeLocale('en_US', 'en')
  const m1 = tz.moment('mercredi 1 juillet 2015 15:00', 'LLLL')
  ok(!m1._locale._abbr.match(/fr/))
  ok(!m1.isValid())

  tz.changeLocale(french, 'fr_FR', 'fr')
  const m2 = tz.moment('mercredi 1 juillet 2015 15:00', 'LLLL')
  ok(m2._locale._abbr.match(/fr/))
  ok(m2.isValid())
})
Exemplo n.º 2
0
test("useMeridian() false if locale doesn't define am/pm but still uses 12-hour format (format will be corrected)", () => {
  tz.changeLocale(french, 'fr_FR', 'fr')
  I18nStubber.setLocale('fr_FR')
  I18nStubber.stub('fr_FR', {'time.formats.tiny': '%-l:%M%P'})
  ok(!tz.hasMeridian())
  ok(!tz.useMeridian())
})
Exemplo n.º 3
0
test("useMeridian() false if locale doesn't define am/pm and instead uses 24-hour format", () => {
  tz.changeLocale(french, 'fr_FR', 'fr')
  I18nStubber.setLocale('fr_FR')
  I18nStubber.stub('fr_FR', {'time.formats.tiny': '%-k:%M'})
  ok(!tz.hasMeridian())
  ok(!tz.useMeridian())
})
Exemplo n.º 4
0
test("format() should promote 12-hour+am/pm into 24-hour if the locale doesn't define am/pm", () => {
  const time = tz.parse('1969-07-21 15:00:00')
  tz.changeLocale(french, 'fr_FR', 'fr')
  equal(tz.format(time, '%-l%P'), '15')
  equal(tz.format(time, '%I%P'), '15')
  equal(tz.format(time, '%r'), '15:00:00')
})
Exemplo n.º 5
0
test('changeLocale(...) should asynchronously curry in a locale by name', assert => {
  const done = assert.async()
  assert.expect(1)
  tz.changeLocale('fr_FR', 'fr').then(() => {
    equal(tz.format(moonwalk, '%c'), 'lun. 21 juil. 1969 02:56:00 UTC')
    done()
  })
})
test('should localize start date', () => {
  I18nStubber.pushFrame()
  tz.changeLocale(french, 'fr_FR', 'fr')
  I18nStubber.setLocale('fr_FR')
  I18nStubber.stub('fr_FR', {
    'date.formats.full_with_weekday': '%a %-d %b %Y %-k:%M',
    'date.formats.medium_with_weekday': '%a %-d %b %Y',
    'date.formats.medium': '%-d %b %Y',
    'date.month_names': ['août'],
    'date.abbr_month_names': ['août']
  })
  const view = createView(commonEvent())
  equal(view.$('.date_field').val(), 'sam. 22 juil. 2017')
  I18nStubber.popFrame()
})
test('renders due date column with locale-appropriate format string', function() {
  tz.changeLocale(french, 'fr_FR', 'fr')
  I18nStubber.setLocale('fr_FR')
  I18nStubber.stub('fr_FR', {
    'date.formats.short': '%-d %b',
    'date.abbr_month_names.8': 'août'
  })
  const view = createView(this.model, {canManage: true})
  equal(
    view.dateDueColumnView
      .$(`#vdd_tooltip_${this.model.id}_due div dd`)
      .first()
      .text()
      .trim(),
    '29 août'
  )
})
test('renders lockAt/unlockAt with locale-appropriate format string', function() {
  tz.changeLocale(french, 'fr_FR', 'fr')
  I18nStubber.setLocale('fr_FR')
  I18nStubber.stub('fr_FR', {
    'date.formats.short': '%-d %b',
    'date.abbr_month_names.8': 'août'
  })
  const model = buildAssignment({
    id: 1,
    lock_at: '2113-08-28T04:00:00Z',
    all_dates: [
      {
        lock_at: '2113-08-28T04:00:00Z',
        title: 'Summer Session'
      },
      {
        unlock_at: '2113-08-28T04:00:00Z',
        title: 'Winter Session'
      }
    ]
  })
  const view = createView(model, {canManage: true})
  const $dds = view.dateAvailableColumnView.$(`#vdd_tooltip_${this.model.id}_lock div`)
  equal(
    $('span', $dds.first())
      .last()
      .text()
      .trim(),
    '28 août'
  )
  equal(
    $('span', $dds.last())
      .last()
      .text()
      .trim(),
    '28 août'
  )
})
Exemplo n.º 9
0
test("hasMeridian() false if locale doesn't define am/pm", () => {
  tz.changeLocale(french, 'fr_FR', 'fr')
  ok(!tz.hasMeridian())
})
Exemplo n.º 10
0
test('changeLocale(...) should synchronously curry in a loaded locale', () => {
  tz.changeLocale(french, 'fr_FR', 'fr')
  equal(tz.format(moonwalk, '%c'), 'lun. 21 juil. 1969 02:56:00 UTC')
})
Exemplo n.º 11
0
test('format() should localize when given a localization key', () => {
  tz.changeLocale(french, 'fr_FR', 'fr')
  I18nStubber.setLocale('fr_FR')
  I18nStubber.stub('fr_FR', {'date.formats.full': '%-d %b %Y %-l:%M%P'})
  equal(tz.format(moonwalk, 'date.formats.full'), '21 juil. 1969 2:56')
})
Exemplo n.º 12
0
      'date.formats.long_with_weekday': '%A, %B %-d',
      'date.formats.medium': '%b %-d, %Y',
      'date.formats.medium_month': '%b %Y',
      'date.formats.medium_with_weekday': '%a %b %-d, %Y',
      'date.formats.short': '%b %-d',
      'date.formats.short_month': '%b',
      'date.formats.short_weekday': '%a',
      'date.formats.short_with_weekday': '%a, %b %-d',
      'date.formats.weekday': '%A',
      'time.formats.default': '%a, %d %b %Y %H:%M:%S %z',
      'time.formats.long': '%B %d, %Y %H:%M',
      'time.formats.short': '%d %b %H:%M',
      'time.formats.tiny': '%l:%M%P',
      'time.formats.tiny_on_the_hour': '%l%P'
    })
    tz.changeLocale('en_US', 'en')
  },

  teardown() {
    tz.restore(this.snapshot)
    I18nStubber.popFrame()
    MockDate.reset()
  }
})

test('parses english dates', () => {
  const engDates = [
    '08/03/2015',
    '8/3/2015',
    'August 3, 2015',
    'Aug 3, 2015',