We are using <obsFromFragment> with commons-ui-datetimepicker in our HTML forms at multiple places. At certain places, we want to use the selected datetime value as encounterDatetime.
Is it possible to use some store some <obs> value as encounter_datetime and not store as obs?
@mddubey our distro might be doing some funny things with date formats, confusing the date picker. Can you validate that this also happens on QA Ref App?
Update - We have analysed the root cause of this issue.
Findings:
Whenever we configure an endDate/startDate to date time picker, internally in its set method - it will try to parseDate (its own scope method).
But while parsing the date, if the assigned value doesn’t match with any 4 regular expression mentioned below (Date formats) - it will try to create new Date object and assign the properties like date, year - one by one.
if (/^\d{4}\-\d{1,2}\-\d{1,2}$/.test(date)) {
/‘yyyy-mm-dd’/ - logic
}
else if (/^\d{4}\-\d{1,2}\-\d{1,2}[T ]\d{1,2}\:\d{1,2}$/.test(date)) {
/‘yyyy-mm-dd hh:ii’/ - logic
}
else if (/^\d{4}\-\d{1,2}\-\d{1,2}[T ]\d{1,2}\:\d{1,2}\:\d{1,2}[Z]{0,1}$/.test(date)) {
/‘yyyy-mm-dd hh:ii:ss’/ - logic
}
else if (/^[-+]\d+[dmwy]([\s,]+[-+]\d+[dmwy])*$/.test(date)) {
/logic
}
In this case for other languages, our assigned value is not matching with their formats and it is going for last flow.
For creating the date object, code used here is “date = new Date(0, 0, 0, 0, 0, 0, 0)”.
Since this value of this date object will be “Sun Dec 31 1899 00:00:00 GMT+0521 (India Standard Time)”, this base value for further operation end in setting the date value is “Sun Dec 31 1899 00:00:00 GMT+0521 (India Standard Time)”.
Fix :
Ideal fix for his issue, instead of using “new Date(0, 0, 0, 0, 0, 0, 0)” - “Sun Dec 31 1899 00:00:00 GMT+0521 (India Standard Time)”, we should use new Date();