• Given a string that represents a date object with no timezone offset, adds the offset based on the client's current timezone, and returns it as a string

    Parameters

    • date: undefined | string

      e.g. 2021-03-25, PDT timezone

    Returns string

    the date with an added offset of the current time "2021-03-25T07:00:00.000Z"

    // suppose the timezone is PDT
    const originalDateString: string = '2021-03-25';
    const originalDate: Date = new Date(originalDateString);
    // originalDate -> Wed Mar 24 2021 17:00:00 GMT-0700 (Pacific Daylight Time)

    const deserializedDateString: string = deserializeDateValue(originalDateString);
    const deserializedDate: Date = new Date(deserializedDateString);
    // deserializedDate -> Thu Mar 25 2021 00:00:00 GMT-0700 (Pacific Daylight Time)