From 6b5adc2504ecae6386f73ae6b3f5bedb54b3b0a1 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Tue, 25 Jun 2024 21:49:44 +0300 Subject: [PATCH] select us date format --- app/javascript/template_builder/builder.vue | 6 +++--- app/javascript/template_builder/field.vue | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/javascript/template_builder/builder.vue b/app/javascript/template_builder/builder.vue index a02de73f..dcfdb788 100644 --- a/app/javascript/template_builder/builder.vue +++ b/app/javascript/template_builder/builder.vue @@ -627,7 +627,7 @@ export default { if (type === 'date') { field.preferences = { - format: Intl.DateTimeFormat().resolvedOptions().locale.endsWith('-US') ? 'MM/DD/YYYY' : 'DD/MM/YYYY' + format: Intl.DateTimeFormat().resolvedOptions().locale.endsWith('-US') || new Intl.DateTimeFormat('en-US', { timeZoneName: 'short' }).format(new Date()).match(/\s(?:CST|CDT|PST|PDT|EST|EDT)$/) ? 'MM/DD/YYYY' : 'DD/MM/YYYY' } } @@ -660,7 +660,7 @@ export default { if (type === 'date') { field.preferences = { - format: Intl.DateTimeFormat().resolvedOptions().locale.endsWith('-US') ? 'MM/DD/YYYY' : 'DD/MM/YYYY' + format: Intl.DateTimeFormat().resolvedOptions().locale.endsWith('-US') || new Intl.DateTimeFormat('en-US', { timeZoneName: 'short' }).format(new Date()).match(/\s(?:CST|CDT|PST|PDT|EST|EDT)$/) ? 'MM/DD/YYYY' : 'DD/MM/YYYY' } } @@ -914,7 +914,7 @@ export default { if (field.type === 'date') { field.preferences = { - format: Intl.DateTimeFormat().resolvedOptions().locale.endsWith('-US') ? 'MM/DD/YYYY' : 'DD/MM/YYYY' + format: Intl.DateTimeFormat().resolvedOptions().locale.endsWith('-US') || new Intl.DateTimeFormat('en-US', { timeZoneName: 'short' }).format(new Date()).match(/\s(?:CST|CDT|PST|PDT|EST|EDT)$/) ? 'MM/DD/YYYY' : 'DD/MM/YYYY' } } } diff --git a/app/javascript/template_builder/field.vue b/app/javascript/template_builder/field.vue index 4085f55c..e171cbd1 100644 --- a/app/javascript/template_builder/field.vue +++ b/app/javascript/template_builder/field.vue @@ -339,7 +339,7 @@ export default { if (this.field.type === 'date') { this.field.preferences.format ||= - (Intl.DateTimeFormat().resolvedOptions().locale.endsWith('-US') ? 'MM/DD/YYYY' : 'DD/MM/YYYY') + (Intl.DateTimeFormat().resolvedOptions().locale.endsWith('-US') || new Intl.DateTimeFormat('en-US', { timeZoneName: 'short' }).format(new Date()).match(/\s(?:CST|CDT|PST|PDT|EST|EDT)$/) ? 'MM/DD/YYYY' : 'DD/MM/YYYY') } }, methods: {