vendredi 22 janvier 2016

Mock Timezone in Jasmine

Is it possible to mock a timezone in Jasmine to test a date object?

I have a function which takes A UTC time string and converts it to a date object.

Using "2016-01-16T07:29:59+0000", I want to be able to verify that the 'local' date object in PST gives as 2016-01-15 23:29:59

I'd like to be able to switch this time zone back to GMT and ensure that the 'local' date is 2016-01-16 07:29:59

(How) is this possible? (I am running my Jasmine spec through Grunt with phantomjs)

My function for reference:

utcDateStringToDateObject: function(dateString){
    return dateString.indexOf('+')>-1 ? new Date(dateString.split('+')[0]) : new Date(dateString);
}

Aucun commentaire:

Enregistrer un commentaire