Friday, August 17, 2018

Ember.js - ember-pikaday not resolving American dates?

Leave a Comment

I am trying to pass a replacement datepicker on the site with the geb tests we are running.

it is failing on handling an American mock test

{{pikaday-input   value=localisedValue   format=(if format format "DD/MM/YYYY")   name=name   placeholder=localisedPlaceholder   onSelection=(action setValue)   id=inputId   classNames="date-placeholder"   tabindex=tabIndex }} 

date.js

import LocalisedTextInput from './localised-text-input';  export default LocalisedTextInput.extend({   setValue(dateValue) {     if(dateValue) {       let valueFormat = this.get('valueFormat') ? this.get('valueFormat') : 'YYYY-MM-DD';        if(valueFormat !== 'date') {         dateValue = window.moment(dateValue).format(valueFormat);       }       else {         dateValue = window.moment(dateValue);       }     }      this.set('localisedValue', dateValue);   } }); 

and the test

def "Agenda Day renders correctly in the US"() {     given:         bootstrapPublishedTestEvent()      and:         def page = asyncTo EditAgendaPage, siteUnderTest      when:         page.mockTimeZone(420)         page.addDay('20/02/2016', 'Day 1')      then:          page.days*.date == ["20/02/2016"] } 

when I comment out page.mockTimeZone(420) -- the test passes.

mockTimeZone is using the TimeShift.js lib

Date = TimeShift.Date; TimeShift.setTimezoneOffset(420);    

there is a bug that if the date from the server is 31/12/2019 - in UK timezone it is correct -- but in the US timezone it shows as 30/12/2019

0 Answers

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment