This commit is contained in:
@@ -2,6 +2,8 @@ const moment = require("moment")
|
|||||||
|
|
||||||
const {storyApi} = require("../../../../../rpdata/api/Story")
|
const {storyApi} = require("../../../../../rpdata/api/Story")
|
||||||
|
|
||||||
|
const ORDINAL_REGEX = /[0-9]{1,2}(st|nd|rd|th)/g
|
||||||
|
|
||||||
module.exports = class {
|
module.exports = class {
|
||||||
onCreate() {
|
onCreate() {
|
||||||
this.state = {
|
this.state = {
|
||||||
@@ -45,11 +47,13 @@ module.exports = class {
|
|||||||
const values = this.state.values
|
const values = this.state.values
|
||||||
|
|
||||||
let fictionalDate = new Date(values.fictionalDate + " UTC")
|
let fictionalDate = new Date(values.fictionalDate + " UTC")
|
||||||
if (values.fictionalDate != "") {
|
if (values.fictionalDate) {
|
||||||
if (Number.isNaN(fictionalDate.getTime())) {
|
if (Number.isNaN(fictionalDate.getTime())) {
|
||||||
this.state.error = `Could not parse ${values.fictionalDate} as date.`
|
this.state.error = `Could not parse ${values.fictionalDate} as date.`
|
||||||
if (values.fictionalDate.includes("th")) {
|
|
||||||
this.state.error += " Try to remove the 'th'."
|
const ordinal = values.fictionalDate.match(ORDINAL_REGEX)[0]
|
||||||
|
if (ordinal != null) {
|
||||||
|
this.state.error += " Try to remove the '"+ordinal.slice(-2)+"'."
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user