Closed DavidGregory084 closed 9 years ago
@brendanator, could you double-check my thinking here? This should allow round-tripping dates of the type constructed by a browser's date input control more easily while storing the date in the server's local timezone.
Set by a date picker in the browser:
JSON.stringify(new Date("Wed Sep 30 2015 00:00:00 GMT+0100 (GMT Daylight Time)")) => "2015-09-29T23:00:00.000Z"
Writing to the database:
// Deserialization scala> "2015-09-29T23:00:00.000Z" match { case Iso8601(date) => date } res0: org.joda.time.DateTime = 2015-09-30T00:00:00.000+01:00 // DateTimeFromLocalDateColumnType.write scala> res0.toLocalDate res1: org.joda.time.LocalDate = 2015-09-30 // Session.setArgument scala> res1.toDate.getTime res2: Long = 1443567600000
Reading back out again:
// Column.readBaseType scala> new LocalDate(res2) res4: org.joda.time.LocalDate = 2015-09-30 // DateTimeFromLocalDateColumnType.read scala> res4.toDateTimeAtStartOfDay res5: org.joda.time.DateTime = 2015-09-30T00:00:00.000+01:00 // Serialization scala> Iso8601(res5) res6: String = 2015-09-29T23:00:00.000Z
Displaying in the browser:
new Date("2015-09-29T23:00:00.000Z") Wed Sep 30 2015 00:00:00 GMT+0100 (GMT Daylight Time)
Looks good :+1:
@brendanator, could you double-check my thinking here? This should allow round-tripping dates of the type constructed by a browser's date input control more easily while storing the date in the server's local timezone.
Set by a date picker in the browser:
Writing to the database:
Reading back out again:
Displaying in the browser: