Skip to content

Enhance date comparison to include date-like strings #32

@JasonAllenCorns

Description

@JasonAllenCorns

Given a data object like

{
  id: 1234567,
  importantDateValue: '12-12-2022'
}

and given a criteria value like

"isNewerThanImportantDate": {
  "criteria": [
    {
      "has": {
        "trait": "importantDateValue",
        "comparison": "younger",
        "value": "12-01-2022"
      }
    }
  ]
}

Expected result should be true since the human-readable dates are different and since the data object date of December 12 is newer than the comparison date of December 1.

Note:

new Date('12-12-2022') ==> Mon Dec 12 2022 00:00:00 GMT-0800 (Pacific Standard Time)
new Date('12-Dec-2022') ==> Mon Dec 12 2022 00:00:00 GMT-0800 (Pacific Standard Time)
new Date('12/12/2022') ==> Mon Dec 12 2022 00:00:00 GMT-0800 (Pacific Standard Time)
new Date('12.12.22') ==> Mon Dec 12 2022 00:00:00 GMT-0800 (Pacific Standard Time)

Date comparison strings could be try'd before comparison. Since younger and older are limited to Date access, some pre-validation could be implemented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions