From bafa3a767ed9e17fe1957814bacbef28214dea3b Mon Sep 17 00:00:00 2001 From: Pablo Date: Wed, 18 Oct 2017 11:28:05 -0200 Subject: [PATCH 1/3] Update README.md --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 6fe0c1f7..b174a072 100644 --- a/README.md +++ b/README.md @@ -399,6 +399,19 @@ var money = MaskService.toMask('money', '123', { // money -> US$ 1.23 ``` +Ex 2: + +``` ts +import { DatetimeMask } from 'react-native-masked-text/lib/masks' +export default class HMask { + static raw(value) { + const mask = new DatetimeMask() + const moment = mask.getRawValue(value, { format: 'DD/MM/YYYY' }) + return moment.format('YYYY-MM-DD') + } +} + + ## Throubleshooting * If the `es2015` error throw by babel, try run `react-native start --reset-cache` From 214d6655cc9507666f76d3b85445b8488dcd9211 Mon Sep 17 00:00:00 2001 From: Pablo Date: Wed, 18 Oct 2017 11:37:59 -0200 Subject: [PATCH 2/3] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b174a072..83c7f17f 100644 --- a/README.md +++ b/README.md @@ -405,9 +405,13 @@ Ex 2: import { DatetimeMask } from 'react-native-masked-text/lib/masks' export default class HMask { static raw(value) { + const format = 'YYYY-MM-DD' const mask = new DatetimeMask() + if (MaskService.isValid('datetime', value, { format: format })) { + return value + } const moment = mask.getRawValue(value, { format: 'DD/MM/YYYY' }) - return moment.format('YYYY-MM-DD') + return moment.format(format) } } From 8b681bcd3a0cfe0a969c767a3ef722a2c5a6e82f Mon Sep 17 00:00:00 2001 From: Pablo Date: Wed, 18 Oct 2017 11:38:41 -0200 Subject: [PATCH 3/3] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 83c7f17f..8bfcb8f0 100644 --- a/README.md +++ b/README.md @@ -403,6 +403,7 @@ Ex 2: ``` ts import { DatetimeMask } from 'react-native-masked-text/lib/masks' +import { MaskService } from 'react-native-masked-text' export default class HMask { static raw(value) { const format = 'YYYY-MM-DD'