Fix #3585 date-time and time support#3651
Conversation
offtherailz
left a comment
There was a problem hiding this comment.
I didn't have time to test it. I'll do it tomorrow morning. But you can start fixing namings and other things
| * @param {object} options to pass to the enhancer | ||
| * @param {string} options.dateType type choosed from ("date", "time", "date-time") | ||
| * @param {string} options.dateField date to use | ||
| * @param {string} options.setDateField function to use to update the date |
There was a problem hiding this comment.
call them props, not fields.
dateProp, setDateProp
| * instead without it will be used as 2019-03-19T23:00:00.000Z (in cql filter), but in the UI it will be used the | ||
| * actual timezone | ||
| */ | ||
| module.exports = ({dateType = "type", dateField = 'date', setDateField = 'onSetDate'} = {}) => compose( |
There was a problem hiding this comment.
"type" is not one of the allowed values. use datetime
There was a problem hiding this comment.
dateType is where to check in the props the prop type = ('time', 'date', 'date-time')
I would call it dateTypeProp
There was a problem hiding this comment.
Ah, ok. Yes, fine. That's a better name
| expect(LocaleUtils.getDateFormat("hr-HR")).toBe("DD/MM/YYYY"); | ||
| expect(LocaleUtils.getDateFormat("pt-PT")).toBe("DD/MM/YYYY"); | ||
| }); | ||
| it('DATE_FORMATS', () => { |
There was a problem hiding this comment.
This test is not useful at all.
There was a problem hiding this comment.
what if you accidentally erase the it-IT date format customization. it will use the default one.
this checks the presence of the customization for the some locales. i'll update the it description
| expect(LocaleUtils.getLocalizedProp('fr-FR', localizedObjectProp)).toBe('title'); | ||
| }); | ||
| it('getDateFormat', () => { | ||
| expect(LocaleUtils.getDateFormat()).toBe("YYYY/MM/DD"); |
There was a problem hiding this comment.
I suppose this is a check for unknown locale. Please describe in a comment
There was a problem hiding this comment.
for getting the default one
web/client/utils/TimeUtils.js
Outdated
| * @param {object} date | ||
| * @return {number} the offset in milliseconds | ||
| */ | ||
| const getTimezoneOffset = (date) => { |
There was a problem hiding this comment.
getTimezoneOffsetMillis, or can be confused with original one
web/client/utils/TimeUtils.js
Outdated
| }; | ||
|
|
||
| /** | ||
| * @param {object} date to get only date parts (without time parts) |
There was a problem hiding this comment.
| * @param {object} date to get only date parts (without time parts) | |
| * @param {Date|string} date to parse |
web/client/utils/TimeUtils.js
Outdated
|
|
||
| /** | ||
| * @param {object} date to get only date parts (without time parts) | ||
| * @return {string} used to compose a UTC date |
There was a problem hiding this comment.
| * @return {string} used to compose a UTC date | |
| * @return {string} date part of the TimeStamp |
| }); | ||
| it('render with value', () => { | ||
| ReactDOM.render(<DateTimeFilter type="date" value={"2017-01-05Z"}/>, document.getElementById("container")); | ||
| ReactDOM.render(<DateTimeFilter type="date" value="2017-01-05T04:04:04Z"/>, document.getElementById("container")); |
There was a problem hiding this comment.
DateTimeFilter should be enhanced, or I'm afraid it will not work with dates or times only
There was a problem hiding this comment.
you mean it should handle partial date or time?
There was a problem hiding this comment.
btw it is using the utcDateWrapper enhancer
| const enddate = this.props.fieldValue && this.props.fieldValue.endDate || null; | ||
|
|
||
| // needed to initialize the time parts to 00:00:00 | ||
| const defaultCurrentDate = moment().startOf("day").toDate(); |
There was a problem hiding this comment.
Don't know why this is here (and in date filter) if is needed to make UTCDateTimePicker work, it should be inside it (enhancer, setting, for instance moment().startOf("day").toDate() as default value.
If has another reason, please explain better.
There was a problem hiding this comment.
This is needed to initialize the time part
Imagine the "date" case:
DateTimePicker component is initialized with a new Date based on that moment and it includes the time part.
then you select a date from the calendar but the time part will remain untouched.
with defaultCurrentDate it changes the time part of the initial value
notice that it does that also for date-time case (we may want to not do it for that case)
i think we can put it in the enhancer enabled by a flag or by the type
There was a problem hiding this comment.
@offtherailz I'll update the enhancer with the defaultCurrentDate = moment().startOf("day").toDate(); at least for "date" format
offtherailz
left a comment
There was a problem hiding this comment.
Only one comment. In addition:
we are waiting for a VM to test this kind of stuff. It should be ready in the next few days.
It should be perfect if we postpone the check of the functionalities when we have that VM (so we don't have to recreate test data every time on our machines).
Now I'm not able to test this without spending a couple of hours configuring the local environment with the required data. I prefer to spend this time to make this data available for testers. @tdipisa what do you think?
…3651) Fix geosolutions-it#3585 added date-time and time support (geosolutions-it#3651) * Add utc enhancer to the dateTimePicker components + tests * Fix tests for date time * tentative fix for date time tests * remove timezone test * fix timeutils test * update var names and tests * Fix date or time values used in cql filter * fix utcDateWrapper test * Fix date problem with firefox * fix failing test on firefox
Fix #3585 added date-time and time support (#3651) * Add utc enhancer to the dateTimePicker components + tests * Fix tests for date time * tentative fix for date time tests * remove timezone test * fix timeutils test * update var names and tests * Fix date or time values used in cql filter * fix utcDateWrapper test * Fix date problem with firefox * fix failing test on firefox
Description
This pr add the support for date-time and time attributes.
Now you can use them in the Attribute Filter field.
Issues
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (check one with "x", remove the others)
What is the current behavior? (You can also link to an open issue here)
date-time and time are not supported
We are not using utc date in the date picker and in the requests they are shifted to UTC
Hours are set to actual date if date only is used
What is the new behavior?
see description
Does this PR introduce a breaking change? (check one with "x", remove the other)
If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...
Other information:
Please note that the date formats are a bit changed since it was not displaying correctly the Year,
and for the hours it was using month instead of minutes