cibernox / ember-power-calendar

Powerful and customizable calendar component for Ember
http://www.ember-power-calendar.com
Other
211 stars 118 forks source link

Remove moment dependency #65

Closed ilucin closed 7 months ago

ilucin commented 7 years ago

Hi @cibernox! Would you consider removing moment dependency? Many people are using alternatives like date-fns or others.

I believe a good plugin shouldn't force you (if possible) too use big dependencies like that one. I really like your work with ember-power plugin family but this is kind of a deal breaker for my projects.

cibernox commented 7 years ago

Yes, I would consider it

The idea is that every action (e.g. onSelect) receives an object, not a Date. That object contains a date property that contains the native Date object. That object at the moment also has a moment property that has the moment-equivalent version of that date, so people can decide what kind of value they want by doing onSelect=(action "whatever" value="moment").

I'd like to maintain the API, but if we remove momentjs the moment property wouldn't be there. The same way, if someone prefers datejs, we could have a datejs property on that object.

That said, it's pretty low in my scale of priorities.

ilucin commented 7 years ago

Great! If you think this is generally a good idea I can try to help you with implementation.

As I can see it, the way to refactor this would be:

  1. extract all current moment usages into functional utility helpers
  2. implement all used utilities
  3. provide an API for i18n stuff that moment gives us out of the box

Of course, maintaining an existing API is important but ember-power-calendar is still in alpha so changes like this are expected.

On the other hand, we can provide a simple migration mechanism for people that still want their moment property to be there. Maybe allow them to reopen power-calendar component class and set moment property on their own and then power-calendar can use it internally (only if provided) when exposing data in actions.

cibernox commented 7 years ago

The challenge is that I use momentjs myself quite a lot internally. Helper functions are reasonably easy to implement, but i18n can be too much. There is a ton of knowledge in momentjs that it's not easy to replicate.

ilucin commented 7 years ago

You're right. I wouldn't replicate it then, only allow to opt-out of it.

mkszepp commented 7 months ago

It a very old issue, but power calendar is already working with meta packages for moment, luxon... There is possible to make also custom meta packages, so evey can use his favorite date libary