Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

Undefined dob is treated by moment as today #353

@jfly

Description

@jfly

We've got a few places where we construct a moment out of a dob:

~/gitting/ccm @kaladin> git grep "moment.*dob"
imports/startup/server/exportResults.js:        let iso8601Date = formatMomentDateIso8601(moment(registration.dob));
imports/startup/server/methods.js:        dob: moment.utc(wcaPerson.dob).toDate(),
imports/startup/server/methods.js:        dob: moment.utc(wcaPerson.dob).toDate(),
imports/ui/pages/editProfile.jsx:    return this.props.user ? formatMomentDate(moment(this.props.user.profile.dob)) : null;
imports/ui/pages/manage/manageCheckin.jsx:                    {formatMomentDateIso8601(moment(registration.dob))}
imports/ui/pages/manage/manageScrambles.jsx:                    {formatMomentDateIso8601(moment(registration.dob))}

Interestingly enough, when you pass undefined into moment, you get today:

> moment(null).format()
"Invalid date"
> moment(undefined).format()
"2017-03-15T11:02:03-07:00"

Maybe the best solution is to create a ccmMoment method that checks for undefined and returns null instead of a moment representing right now?

The delegate crash course says "If you still end up missing the date of birth for a competitor, please leave it blank (i.e. "0000-00-00") and do not enter bogus dates such as "1900-01-01"."

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions