Skip to content
This repository was archived by the owner on Nov 12, 2018. It is now read-only.

Defect using Firefox with the 'format' option #4

@house9

Description

@house9

I came across the following issue with Firefox and possible timezone issue with Safari and Chrome.

  • Firefox 38.0.5 on Mac OS X and Windows 7
  • Running in Pacific timezone

Probably a bit of an edge case and there is an ok workaround:

pickadateOptions: {
  format: "mm/dd/yy",
  onSet: function (context) {
    console.log(context);
  }
}

selecting 9/20/2015 on Firefox will log:

Object { select: 1442707200000 } // toJSON() -> "2015-09-20T00:00:00.000Z"
// followed immediately by 
Object { select: -1713027600000 } // toJSON() -> "1915-09-20T07:00:00.000Z"

on Chrome:

Object {select: 1442707200000} // toJSON() -> "2015-09-20T00:00:00.000Z"
// followed immediately by 
Object {select: 1442732400000} // toJSON() -> "2015-09-20T07:00:00.000Z"

The issue appears to be coming from the use of Date.parse here: https://github.com/immense/knockout-pickadate/blob/master/knockout-pickadate.js#L148

Workaround

Use the update_as_date: true option when using the format option

pickadateOptions: {
  min: -10,
  format: "mm/dd/yy",
  update_as_date: true,
  onSet: function (context) {
    console.log(context);
  }
}

selecting 9/20/2015 will log only:

Object { select: 1442707200000 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions