515 questions
2 votes
1 answer
129 views
Handling YYYY-MM-DD as UTC
I use this package and my function is this: const formatDate = ( date: string | Date, dateFormat: string = 'PP p', timezone?: string, ) => { const zoneDate = toZonedTime(date, timezone ?? '...
1 vote
1 answer
54 views
How to dynamically import a date-fns language module in an Angular Ionic application
I am replacing moment with date-fns in my Ionic Angular project. I run with many possible languages, so did not want to statically import them all, and make the bundle bigger. I am trying the ...
0 votes
1 answer
60 views
How to allow negative years (i.e. BCE years) with MUI X Date Pickers?
I was messing about with the minDate prop on the MUI X Date Picker (specifically the DatePicker component). I was trying to set the minDate to a date with a negative year (i.e. a BCE year) in order to ...
0 votes
0 answers
48 views
timezone-mock gives 'Unhandled type passed to MockDate Constructor: object' when using ContextOptions with date-fns 'isSameDay'
Here's the code to reproduce it: import timezoneMock from 'timezone-mock'; import { utc } from '@date-fns/utc'; it('breaks', () => { timezoneMock.register('US/Eastern') const now = new Date(); ...
0 votes
1 answer
33 views
FormatDistance without "hours ago"
When using date-fns, how can I use intlFormatDistance such that for a duration less than 24 hours, it displays "today" or "yesterday", instead of "x hours ago". Example: ...
1 vote
2 answers
307 views
How to properly import a modular JS library in Rails using Importmap (case date-fns)?
In my Rails 8 app I'm using Importmap and I would like to use date-fns in an appropriate manner given only one functionality and a couple of locales from that JS library are needed. Below is what I ...
0 votes
2 answers
77 views
How to create a type definition for an array of objects without using any[]?
I am using the date-fns library to get the months between a couple of date values using the eachMonthOfInterval function, like so: const startingMonth = "2024-10-01 00:00:00"; const ...
0 votes
0 answers
38 views
Formatted date with date-ins doesn't update on re-renders in React component
Having a strange issue using date-fns with react. Didn't encounter anything like this before. Basically there is a component which gets a year number as a prop, which is then used to create a date ...
0 votes
1 answer
50 views
the created_at search in prisma aggregateRow mongodb does not work
I use the date-fns library to work with dates. the code provided their methods. prisma: 5.22.0 @prisma/client: 5.22.0 async getAllOnYear() { const date = new Date() const startYear = ...
1 vote
0 answers
36 views
DST timing is getting wrong for Egypt
The DST timing is wrong in countries where DST starts at 12 a.m., such as (Lebanon ,Cuba, Egypt). The library we're utilizing for UTC dates Package version: date-fns: 2.30.0, date-fns-tz: 1.3.8. ...
0 votes
0 answers
61 views
Issues with javascript dates /times on server vs local browser (react)
I have a set of code running that checks two dates. If those two dates/times occurred on the same day, one course of action is taken. If they are not, a different set of components are shown. The code ...
0 votes
2 answers
967 views
date-fns function returns incorrect response for isSameDay; So does javascript comparison
I have been using the date-fns function "isSameDay" to test if two actions take place on the same day. The function is given two standard javascript date objects. We recently found a bug ...
1 vote
1 answer
2k views
Angular Material Datepicker - Localization for Material18+
I use Angular Material 18 and the Datepicker component. I try to use the local variation and try to avoid moment. The reason for this is that moment is deprecated. There I try use the DateFns ...
0 votes
1 answer
464 views
How to use date-fns instead of dayjs when creating custom calender header for MUI Date Picker
I am trying to add a custom calender header for the MUI Date Picker component but am running into troubles when changing the default dayjs type to date-fns. Here is my Date Picker component and custom ...
1 vote
2 answers
1k views
Why if I try to use the node.js module 'date-fns' I get the TypeScript compilation error TS1005?
I'm trying to use the format function of the Node.js module date-fns. Some info about my system (obtained by the command ng --version) is reported below: Angular CLI: 13.2.0 Node: 16.13.2 Package ...