[ALOY-263] Implement Ti.UI.Picker parser (DATE & DATE_TIME)
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-05-09T00:38:14.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Alloy 1.4.0, 2014 Sprint 08 |
Components | XML |
Labels | notable, qe-testadded |
Reporter | Tony Lukasavage |
Assignee | Tim Poulsen |
Created | 2012-09-13T06:11:33.000+0000 |
Updated | 2014-06-20T22:54:57.000+0000 |
Description
Need to determine a valid format for dates in the markup to be passed to the minDate, maxDate, and value properties, since they expect Javascript Date objects.
Tried this today, of course it failed, then I found this ticket.
Seems like the obvious way to implement support would be to simply pass the values of the minDate, maxDate, and value attributes to the
new Date()
constructor. Thus, values could be any string that the Date() constructor accepts. Alternatively, since moment.js is built in, you could pass the values to moment() and accept whatever strings it supports.PR: https://github.com/appcelerator/alloy/pull/349 Functional test 1. Run the associated ALOY-263 test app. You should get a date-style picker. 2. Edit the views/index.xml or styles/index.tss and change any of the value, minDate, or maxDate values to an invalid date string (e.g. 2013,0,0). Then build. The build will fail with an error message noting which field contained the invalid date. 3. Note that the value of the text field, while a parseable date string, is not converted to a date object (or its toString() representation).
PR merged
Reopening due to feedback from Ben that some valid JavaScript date strings are not working as expected.
Reimplemented using moment.js to support a broader variety of string formats for the date/time values. In this new implementation, you cannot use milliseconds as a value for any of the date attributes. But anything else parseable by moment should work. New PR merged, https://github.com/appcelerator/alloy/pull/367
Verified working as expected on iOS 7, Android 4.3 and MobileWeb. TiSDK 3.3.0.v20140507163312 Alloy 1.4.0-dev Appcelerator Studio 3.3.0.201405011408 CLI 3.3.0-dev Closing.