Dayjs: Differences to moment?

Created on 25 Apr 2018  路  17Comments  路  Source: iamkun/dayjs

Could you add a section to the README.md that explains the differences to moment? Why is it faster/smaller? What features are missing? Are the parts of the API that are different? What was your motivation to "reinvent" the wheel?

Most helpful comment

Will do

All 17 comments

+1

This is probably going to be the question front of mind for most people considering DayJS: Why DayJS instead of MomentJS?

Personally, my team is moving away from moment and I'd like to know what tradeoffs I'd be making by choosing DayJS and if it meets my needs or not (eg: timezones or i18n concerns).

Either way, best of luck. This looks like an incredible project! 馃憤

Will do

Is dayjs fully compatible with moment? I hope to use alias in webpack to replace moment with dayjs, but I cannot ensure if it is ok to do it. Is there any guidelines?

There are some functions that are not yet implemented, and others are available through plugins. Try to change the alias, and see if everything works fine

Well, I found the second argument of Dayjs#diff is different, it accepts singular but Moment#diff accepts plural.

@acrazing Dayjs accepts both I think

@xxyuk um.. I use typescript to check it, its singular only and is required in index.d.ts: https://github.com/iamkun/dayjs/blob/master/index.d.ts#L57

Oh I see.

We might could update it like this ? I'm not sure

export type UnitType = 'millisecond' | 'milliseconds' | 'second' | 'seconds' | 'minute' | 'minutes' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year' | 'date'

But I'm not good with TS, anyone could send a PR to fix this?

One thing I've just come across that's different is Moment accepts an array on constructor - e.g. moment([2018, 1, 1]) but dayjs doesn't seem to know how to parse this.

@zediah Yes, Day.js can't parse array or object at this time.

https://github.com/you-dont-need/You-Dont-Need-Momentjs

Here is a simple comparison between Day.js, Moment.js, Luxon, Native Date and Date-fns.

Would also be good if the readme mentioned Luxon, which is an immutable moment-js descendent.

It looks like all of these Get + Set functions are missing from dayjs, even with all plugins enabled https://momentjs.com/docs/#/get-set/

@niftylettuce may be you are wrong.

@xxyuk correct, I am wrong in the sense that the plural versions are not available, https://github.com/iamkun/dayjs/blob/dev/docs/en/API-reference.md#get-and-set, e.g. hour() exists but not its alias hours(). just discovered this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

paraself picture paraself  路  3Comments

fes300 picture fes300  路  5Comments

Newbie012 picture Newbie012  路  4Comments

Sunrise1970 picture Sunrise1970  路  4Comments

axelg12 picture axelg12  路  4Comments