Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
19 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 ...
louisch's user avatar
  • 316
0 votes
0 answers
22 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(); ...
AncientSwordRage's user avatar
-1 votes
1 answer
29 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: ...
Ben's user avatar
  • 16.7k
1 vote
2 answers
117 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 ...
user502052's user avatar
  • 15.3k
0 votes
2 answers
51 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 ...
Harish's user avatar
  • 528
0 votes
0 answers
28 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 ...
Hayk Safaryan's user avatar
0 votes
1 answer
31 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 = ...
Mezantrop's user avatar
0 votes
0 answers
18 views

Is there a way to consistently load a `date-fns` locale with fallback from 4-letter to 2-letter language code?

I'm feeding the value of navigator.language into await import('.../date-fns/locales/${languageCode}') which fails for de-DE as date-fns does not define de-DE, but it does de. I find myself manually ...
Irfy's user avatar
  • 9,627
1 vote
0 answers
24 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. ...
shaily rajput's user avatar
0 votes
1 answer
51 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 ...
Joshua Foxworth's user avatar
0 votes
2 answers
473 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 ...
Joshua Foxworth's user avatar
1 vote
1 answer
1k 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 ...
LeO's user avatar
  • 5,316
0 votes
1 answer
312 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 ...
Dov Royal's user avatar
1 vote
2 answers
770 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 ...
User051209's user avatar
  • 2,568
0 votes
0 answers
34 views

Timezone Conversion from UTC to User Time Zone, on Prod vs. Dev?

I have this node.js code. import {toZonedTime} from 'date-fns-tz' function utcHoursToUserTimeZone_date(utcTimeslot, targetDay, userTimeZone) { const [hour, minute] = utcTimeslot.split(":&...
VikR's user avatar
  • 5,142

15 30 50 per page
1
2 3 4 5
35