Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Substitute for moment.js #195

Closed
chaffeqa opened this issue Sep 19, 2020 · 7 comments · Fixed by #202
Closed

Substitute for moment.js #195

chaffeqa opened this issue Sep 19, 2020 · 7 comments · Fixed by #202

Comments

@chaffeqa
Copy link

momentjs is officially not being supported which makes sense... especially for this project which is 100% nodejs based afaik.

The fact that you have to install both momentjs and the locals to support this library (which is included in many other libraries that may not even use it... like we do for bulljs) it would be great if it was lighter in its dependencies.

Is there something I could help contribute to move in that direction?

@harrisiirak
Copy link
Owner

@chaffeqa there have been some discussion in the past about replacing momentjs: #144
Also, there is a pretty cool fork that uses luxon instead of momentjs: https://github.com/tjk/cron-parser

I haven't evaluated the idea of using luxon but what I'm seeing over that fork looks very promising. Other option is to use DayJS (\w Timezone Plugin) which should lead to even smaller bundle.

If somebody is brisk enough to formalize it as a PR, I would be more than willing to contribute and help to get this merged as soon as possible.

@chaffeqa
Copy link
Author

oooo nice! yeah i think the issue is that other libs use this one, such as https://github.com/OptimalBits/bull/blob/develop/package.json#L23

Actually looking at date.js... i think you made it very easy to move away from moment... let me see if i can find some time

@fregante
Copy link

I don’t think this module should concern itself with timezones. If people want to run cronjobs on zones other than UTC, they can use their own library to add/subtract the hours (if a library is needed at all)

I’ve been looking for a lightweight crontab parser and I’ve found that they all weigh 500kb minified, which is a whole lot. Now I see why that is: Moment.

https://bundlephobia.com/result?p=cron-parser@2.16.3

@elnygren
Copy link

https://github.com/luoxlgh/cron-parser fork that uses date-fns, ie. just regular Date which is almost certainly what we want here. If people want to use $TheirDateTypeOfChoice, they can just map to it from Date. That way this library can have minimal deps and generic but still useful for everyone functionality.

@JeppeLarsen
Copy link

I have just published an npm-package called lw-cron-parser that excludes timezone functionality and utilizes Day.js instead of Moment-Timezone. I think this is the best alternative until pull request #196 is merged.
The project is forked from the newest version of cron-parser and utilizes Day.js@1.9.3.

@fregante
Copy link

https://github.com/cheap-glitch/mi-cron

A collaborator of mine wrote this. It’s super small and just outputs a Date object which you can manipulate as you wish, if needed at all.

@baxang
Copy link

baxang commented Nov 3, 2020

For me, time zone support completes this library 😃 so I hope the functionality remains.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants