You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
openMomentRe;let()="March 7 2009 7:30pm EST"|>Js.String.replace "EST""-0500"|> (funs=> momentWithFormat s "MMMM D YYYY h:mma Z")
|>Moment.add duration::(duration 12`hours)
|>Moment.defaultFormat
|>Js.log
I wanted to make a date manipulation example for the bucklescript cookbook, but I think the API currently leaves a bit to desire. I realize most of this is from trying to model it very closely to the js API, but just to get this on the record. The issues I have with it are:
momentWithFormat is a bit of a non-sensical name
momentWithFormat is not in pipe form, so I have to use a lambda function to fit it into the pipeline
momentWithFormats arguments aren't labelled, and so very easy to mix up. Doubly so since it's not in pipe form either (I wasted a ton of time on this, trying to figure out why the date passed in was considered invalid...)
I still find it inconsistent to not have the moment... functions in the Moment module (We've talked about this before though)
Internally the moment constructor is called createLocal, but I'd use different names depending on the variant. monent() can be now (or make, but that's less specific), moment('Jul 7 2017') can be parse, and its variants parseWithFormat etc., and the other construction forms can be fromObject, fromDate, fromUnixTime, fromArray and clone.
I wanted to make a date manipulation example for the bucklescript cookbook, but I think the API currently leaves a bit to desire. I realize most of this is from trying to model it very closely to the js API, but just to get this on the record. The issues I have with it are:
momentWithFormat
is a bit of a non-sensical namemomentWithFormat
is not in pipe form, so I have to use a lambda function to fit it into the pipelinemomentWithFormat
s arguments aren't labelled, and so very easy to mix up. Doubly so since it's not in pipe form either (I wasted a ton of time on this, trying to figure out why the date passed in was considered invalid...)moment...
functions in theMoment
module (We've talked about this before though)Moment.add
sduration
argument label seems redundantdefaultFormat
is not a verb, like most other function namesdefaultFormat
is also an actual property inmoment.js
, which is a bit confusing.The text was updated successfully, but these errors were encountered: