Skip to content

Format JS Date Objects #1

@AKST

Description

@AKST

Moment.js has the ability to accept javascript Date objects as parameters (documented here), and it would be great if the API of these bindings supported this. As far as I'm aware the only library that wraps the javascript date object is purescript-datetime (well at least according my quick search of bower anyways), so my thinking it would only be natural to add a parseDate function to this library that looked something like this.

import Data.Date

-- 
-- may want to double check this...
--
foreign import parseDate """
  function parseDate(date) {
   return moment({ unit: date });
  }
  """ :: Date -> Moment

Date in purescript-datetime, is just a new type wrapper of the 'native' javascript date object, so you could just pass it to moment.js like so.

moment({ unit: date });

But it would come at the cost of adding an additional dependency to this library, and I'm not sure how big of a deal this is in purescript. Thoughts?

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