Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
#610 change date format mm-dd-yyyy to mm/dd/yyyy for Date.parse
Browse files Browse the repository at this point in the history
  • Loading branch information
gchi25 committed Feb 21, 2023
1 parent e6e876a commit 63289a5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 10 additions & 2 deletions services/dateHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function validateDateAgainstAcceptance({ criterion, userInputDate }) {
) {
acceptanceDate = figureOutAcceptanceDate(encodedDate, determiner)
} else {
acceptanceDate = toDate(Date.parse(encodedDate))
acceptanceDate = toDate(dateParse(encodedDate))
}
checkResult = checkUserDate(userInputDate, determiner, operator, acceptanceDate)
// checking to see if the inputted date is valid / complete
Expand Down Expand Up @@ -139,4 +139,12 @@ function checkDateValid(month, day, year) {
return validityCheck === INCOMPLETE ? "" : validityCheck
}

export { validateDateAgainstAcceptance, checkDateValid }
function dateParse(inputDate) {
const m = inputDate.match(/^(\d{1,2})-(\d{1,2})-(\d{4})$/)
if (m) {
inputDate = m[1] + "/" + m[2] + "/" + m[3]
}
return Date.parse(inputDate)
}

export { validateDateAgainstAcceptance, checkDateValid, dateParse }
6 changes: 3 additions & 3 deletions store/criteria.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Vue from "vue"
import stringToHash from "../services/stringToHash"
import { validateDateAgainstAcceptance } from "~/services/dateHelper"
import { validateDateAgainstAcceptance, dateParse } from "~/services/dateHelper"

export const state = () => ({
eligibilityCriteria: {},
Expand Down Expand Up @@ -75,8 +75,8 @@ export const getters = {
}
// need this to be swapped if passing in a state I.E. testing
const userInputDate = criterion.test
? Date.parse(theGetters.getResponseByEligibilityKey(theState)(criterion.criteriaKey))
: Date.parse(theGetters.getResponseByEligibilityKey(criterion.criteriaKey))
? dateParse(theGetters.getResponseByEligibilityKey(theState)(criterion.criteriaKey))
: dateParse(theGetters.getResponseByEligibilityKey(criterion.criteriaKey))
return validateDateAgainstAcceptance({
criterion,
userInputDate,
Expand Down

0 comments on commit 63289a5

Please sign in to comment.