Skip to content

Commit

Permalink
ante: fix date parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
ChlodAlejandro committed Sep 1, 2023
1 parent 9ecbc4a commit ae127dc
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/modules/ante/ui/components/RevisionDateGetButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ function initRevisionDateGetButton() {
rvprop: 'timestamp'
} ).then( ( data ) => {
this.dateInputWidget.setValue(
// ISO-format date
data.query.pages[ 0 ].revisions[ 0 ].timestamp.split( 'T' )[ 0 ]
);
this.dateInputWidget.setDisabled( false );
Expand Down
6 changes: 3 additions & 3 deletions src/modules/ante/ui/pages/CopiedTemplateRowPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,9 @@ function initCopiedTemplateRowPage() {
this.copiedTemplateRow[ field ] = value ? 'yes' : '';
} else if ( input instanceof mw.widgets.DateInputWidget ) {
this.copiedTemplateRow[ field ] = value ?
new Date( value + 'T00:00:00Z' ).toLocaleDateString( 'en-GB', {
year: 'numeric', month: 'long', day: 'numeric'
} ) : undefined;
window.moment( value, 'YYYY-MM-DD' )
.locale( 'en' )
.format( 'YYYY-MM-DD' ) : undefined;
if ( value.length > 0 ) {
this.fieldLayouts[ field ].setWarnings( [] );
}
Expand Down
6 changes: 3 additions & 3 deletions src/modules/ante/ui/pages/MergedFromTemplatePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,9 @@ function initMergedFromTemplatePage() {
this.mergedFromTemplate[ field ] = value ? 'yes' : 'no';
} else if ( input instanceof mw.widgets.DateInputWidget ) {
this.mergedFromTemplate[ field ] = value ?
new Date( value + 'T00:00:00Z' ).toLocaleDateString( 'en-GB', {
year: 'numeric', month: 'long', day: 'numeric'
} ) : undefined;
window.moment( value, 'YYYY-MM-DD' )
.locale( 'en' )
.format( 'YYYY-MM-DD' ) : undefined;
if ( value.length > 0 ) {
fieldLayouts[ field ].setWarnings( [] );
}
Expand Down
6 changes: 3 additions & 3 deletions src/modules/ante/ui/pages/MergedToTemplatePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ function initMergedToTemplatePage() {
this.mergedToTemplate[ field ] = value ? 'yes' : 'no';
} else if ( input instanceof mw.widgets.DateInputWidget ) {
this.mergedToTemplate[ field ] = value ?
new Date( value + 'T00:00:00Z' ).toLocaleDateString( 'en-GB', {
year: 'numeric', month: 'long', day: 'numeric'
} ) : undefined;
window.moment( value, 'YYYY-MM-DD' )
.locale( 'en' )
.format( 'YYYY-MM-DD' ) : undefined;
if ( value.length > 0 ) {
fieldLayouts[ field ].setWarnings( [] );
}
Expand Down
6 changes: 3 additions & 3 deletions src/modules/ante/ui/pages/SplitArticleTemplateRowPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ function initSplitArticleTemplateRowPage() {
input.on( 'change', ( value: string ) => {
if ( input instanceof mw.widgets.DateInputWidget ) {
this.splitArticleTemplateRow[ field ] = value ?
new Date( value + 'T00:00:00Z' ).toLocaleDateString( 'en-GB', {
year: 'numeric', month: 'long', day: 'numeric'
} ) : undefined;
window.moment( value, 'YYYY-MM-DD' )
.locale( 'en' )
.format( 'YYYY-MM-DD' ) : undefined;
if ( value.length > 0 ) {
fieldLayouts[ field ].setWarnings( [] );
}
Expand Down

0 comments on commit ae127dc

Please sign in to comment.