Closed vanodevium closed 8 months ago
@justin-schroeder sorry for tagging, if there is more date-fns function that need to be migrated here I will move them ❤️
@vanodevium We do have a sameDay
function for simple equality, but help me understand before
and after
. Is this pure syntactic sugar? Since tempo’s primitive is native Date objects you can compare them directly:
const dateA = new Date()
const dateB = new Date('2012-11-10')
dateA > dateB // true
@justin-schroeder
yeap, these methods are simply sugar
main goal: I can compare not only Date instances, but strings
Something like
before(new Date(), '2024-02-23');
before(tempoInstance, '2024-02-23');
before(tempoInstance, '2024-02-23 00:01:02');
before(tempoInstance, new Date());
before(tempoInstance1, tempoInstance2);
All these variants works as expected -> true/false
friendly reminder: sameDay() isn't equal() because it skips time.
I think i can get onboard with the syntax sugar since it should all tree shake out nicely.
It would be nice to have methods for comparing dates like before, equal and after