-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strange Date Transformation behavior #698
Comments
So I believe I may have solved my own issue... I still do not know why the built in ISO date formatter doesn't work however I created my own
this seems to work just fine, unit tests are passing with valid dates now. |
Just to add to this. I couldn't get the solution above to work but it did steer me into the right directions so much appreciated. I made some tweaks and this works for me.
|
Another Fix: open class ISODateTransform: TransformType {
} |
Hello,
Before this library used to just transform dates without having to specify a date transform function (at least this is the behavior I saw).
So for example
Given the date is of format "2016-12-09T13:37:27.262Z", it would transform this date properly without me having to specify that it was indeed a date.
My current model is failing to parse the date correctly for some reason. I've tried both the example given on the read-me, I've looked at the "closed" issues regarding date formatting and I've tried to use their examples as well...still no luck.
Ive tried these date transforms
My unit test...
which produces...
Clearly, the date I'm giving it isn't 1970...and the above date is indeed an ISO formatted date. The server I'm running is Express/Mongo and I'm simply using the Date.now javascript call to generate a date. Also, the Schema on the Mongo model is of type 'Date'.
Here is my Trip model
Again, as stated above, I've tried using both the DateTransform() and the ISO8601DateTransform().
If I use the DateTransform function, my unit test will "pass" because the date property will no longer be nil however it will be the 1970 date which isn't correct.
If I use the ISO8601DateTransform, the property is nil and the unit test will fail because it was expecting the date to not be nil.
Before I would just specify that the property was a "date" and it would transform everything correctly without me having to specifically set a DateTransform tuple for the mapping. I don't know exactly what I am doing incorrectly here.
==== Updated just to make it look prettier =====
The text was updated successfully, but these errors were encountered: