react-native-masked-text icon indicating copy to clipboard operation
react-native-masked-text copied to clipboard

Current date format is not according moment ISO8601

Open andradefil opened this issue 6 years ago • 4 comments

According moment docs the current pattern for ISO8601 is YYYY-MM-DDTHH:mm:ssZ and not DD/MM/YYYY HH:mm:ss. I not understand the exact point where the date or if is converted to a global pattern before be applied to the mask passed as argument. All tests cover the date in numeric format, the date is converted from react component before be pass to getValue function in datetime.mask.js?

andradefil avatar Jan 05 '19 21:01 andradefil

Sorry man, but I didn't understand your question. This lib is for masked texts, we use moment just to validate if you put a valid date into the masked value and to get raw date value using getRawValue func.

bhrott avatar Jan 06 '19 23:01 bhrott

Sorry man, I not explain the question properly. I have the follow situation:

<TextMask
                value={this.state.alert.date}
                type={'datetime'}
                options={{
                        format: 'DD/MM/YYYY'
                }}
            />

The value in this.state.alert.date is 2018-12-30T00:00:00. When mask my date, it masked to 20/18/12. Per my debug I think that is because the default format that Lib accept the date is DD/MM/YYYY HH:mm:ss. I would like to suggest the 'convertion' of format YYYY-MM-DDTHH:mm:ssZ before mask because is the official format to datetime. I would be grateful to make a pull request if this change is welcome.

andradefil avatar Jan 07 '19 12:01 andradefil

<TextMask value={this.state.alert.date} type={'datetime'} options={{ format: 'DD/MM/YYYY' }} />

cuongnguyen290797 avatar Aug 02 '19 09:08 cuongnguyen290797

<TextMask value={this.state.alert.date} type={'datetime'} options={{ format: 'DD/MM/YYYY' }} />

What is the output for input 2018-12-30T00:00:00 and this configuration? In my test was 20/18/12 that not would be the right output.

andradefil avatar Aug 02 '19 12:08 andradefil