selectedDate: Sun Feb 15 2015 00:00:00 GMT-0800 (PST)
this.state.value: 2015-02-15
valueAsDate: Sat Feb 14 2015 16:00:00 GMT-0800 (PST)
Looks like onChange is receiving the correct date; it's the new Date(...) value that's erroneous. From the Date docs on MDN (link):
Note: parsing of date strings with the Date constructor (and Date.parse, they are equivalent) is strongly discouraged due to browser differences and inconsistencies. Support for RFC 2822 format strings is by convention only. Support for ISO 8601 formats differs in that date-only strings (e.g. "1970-01-01") are treated as UTC, not local.
Looks like this works fine:
new Date(2015, 02, 15) // returns proper date in PST: Sun Mar 15 2015 00:00:00 GMT-0700 (PDT)
Closing as the component isn't behaving incorrectly. However, we could use better docs here. Will open a follow-up issue.
See https://github.com/palantir/blueprint/issues/955#issuecomment-345784633. Pasted here:
So here's what I'm seeing:
Looks like
onChange
is receiving the correct date; it's thenew Date(...)
value that's erroneous. From the Date docs on MDN (link):Looks like this works fine:
Closing as the component isn't behaving incorrectly. However, we could use better docs here. Will open a follow-up issue.