Creation dates showing as ####-11-29 when entered as YYYY-00-00 in search results
|Assignee:||José Raddaoui Marín||% Done:|
|Category:||Search / Browse||Estimated time:||2.00 hours|
|Target version:||Release 2.0.0|
|Google Code Legacy ID:||Tested version:|
Navigate to Browse > archival descriptions
Filter the search results to Series
Note that all the dates showing are YYYY-11-29
Dates with only a year entered will display only the year
#4 Updated by José Raddaoui Marín over 8 years ago
- Status changed from New to In progress
We have a little problem here.
If a start/end date is entered without month or day, MySQL stores those values like zeros. For example:
2013-06 will be 2013-06-00 in the database
1983 will be 1983-00-00 in the database
The problem happens when you transform those dates into PHP/ElasticSearch dates. Zero values are not allowed in ISODateTimeFormat and they are transformed into the previous date. So:
2013-06-00 --> 2013-05-31
1983-00-00 --> 1982-12-00 --> 1982-11-30 (in two steps)
First thing I think we'll need to do is change those zeros before transforming the date, so the dates in ElasticSearch looks like:
Start date cases:
2013-06-00 --> 2013-06-01
1983-00-00 --> 1983-01-01
End date cases:
2013-06-00 --> 2013-06-30
1983-00-00 --> 1983-12-31
With different start/end cases to allow a proper date range search (when we include the date range search in 2.x)
But then we have the problem about how are we going to show those dates in the search results. I'll need to do a little more research to see if we can add a property to the modified dates in ElasticSearch, so we can modify it back before showing the date.
Please, let me know if you have any thoughts.
#7 Updated by Dan Gillean over 8 years ago
- Status changed from QA/Review to Verified
I don't fully understand all the technicalities behind this, but currently it seems to be working in the interface.
Many people will only enter one date - at which point the start and end dates are automatically populated for start and end. In these cases, though they should NOT be saved as such, for searching purposes we must assume that if the date is 1980, on a search it will be treated as Start = 1980-01-01 and End = 1980-12-31
I wonder if we can't just make a rule that whenever 2 zeros appear in a date that are NOT part of a larger number (such as 2000), they are stripped?
Anyways, this seems to be working now, so I'll clear this issue and let you work out the details! :D