Closed ChuckJonas closed 3 years ago
Leaning toward option C & 0-11
. With this approach you would be able to pass the object directly into momentjs
const today = moment({ year:2019, month: 10, day: 3 });
day.js
(popular alternative), does not support this yet, but may at some point
For Salesforce Date (no time) fields, the API returns a string in the format
YYYY-MM-DD
.Without much thought, I choose to parse this to a Javascript
Date
object. This causes timezone related issues, which often result in a Date saved to salesforce being off +- 1 day.In a minor version, I'm thinking I can add some consistency by converting the Date to UTC (without timezone translation) before serialization.
However, the issue still persists that a "Calendar Date" SHOULD NOT be represented as a moment in time....
In a major version (because this will be a breaking change), I'm thinking we should adopt one of the following...
Type Format
A:
string
mirroring salesforce.PROS:
CONS:
B:
[number, number, number]
tuple.PROS:
[2019, 10, 27]
CONS:
year,month,day
C:
{year: number; month: number; day: number;}
ObjPROS:
CONS:
Month Format
If we go with option
B
orC
, then we also need to decide if we want to store month as 0-11 or 1-12...0-11
Pros:
Date
Object.Cons:
1-12
Pros:
Cons:
Date
Object.