Questions tagged [moment-range]

Fancy date ranges for Moment.js.

13 questions
3
votes
1 answer

Moment.js: "TypeError: momentRange.range" when using with moment-range

I have problem using all 3 of the packages together. I define them like this: var moment = require('moment-timezone'); var momentRange = require('moment-range'); And when I want to use the moment-range functions, I'm trying to call it like…
2
votes
1 answer

Moment not extendable with moment-range

I'm using "moment": "^2.29.1", "moment-range": "^4.0.2", to get the range between two dates. Vite with Vue3 and typescript. Locally, eveything works fine. But when deploying to Netlify I get the following error: Cannot add property range, object is…
Madriesen
  • 498
  • 2
  • 8
  • 22
2
votes
3 answers

Merge overlapping date ranges

How can I merge overlapping date ranges, on an array? I have an array of dates: const dates = [ {startDate: "2020-03-19T00:00:00+01:00", endDate: "2020-03-20T00:00:00+01:00"}, {startDate: "2020-03-09T00:00:00+01:00", endDate:…
JrGodoi
  • 21
  • 5
1
vote
2 answers

Split a datetime range in individual day slots e.g. access the number of minutes for each individual day present in a datetime range

I have a start date object and an end date object in javascript e.g. var startDate = moment("2019-04-22T09:20:00+05:00"); var endtDate = moment("2019-04-25T11:00:00+05:00"); now I want to have an output like this [880,1440,660] //array for the…
1
vote
2 answers

Moment js import is not working correctly with angular

I have a problem like this. I am building an angular application in there I am going to use moment-range and moment js. I have imported it on the components where I need it. This is that component.ts files. It gives me an error like this. import {…
dwp
  • 908
  • 4
  • 24
  • 42
0
votes
0 answers

How can I prevent the variable from being undefined?

Update: I checked if setDate() is called from ngOnInit: it is. Also I specified the variables: rentalStartInput is an string Array and contains the real dates with I get from the other component (see picture below). rentalStart is a Date, right now…
Mia
  • 17
  • 6
0
votes
0 answers

How to find overlapping time intervals in a multidimensional array of Date objects

I am trying to do two things with a data structure that is quite complex. For the following structure: [ [ { start: 2020-01-01T02:45:00.000Z, end: 2020-01-01T04:30:00.000Z }, { start: 2020-01-01T00:15:00.000Z, end: 2020-01-01T02:00:00.000Z…
thomasbishop
  • 73
  • 1
  • 8
0
votes
1 answer

Connect moment-range with sails backend

I want to get date range between start_time and end_time. var newrange = sails.moment.range(start_time, end_time); But it says, TypeError: sails.moment.range is not a function
0
votes
1 answer

Mongoose: Reduce from many queries to one

I currently have a setup with multiple requests to the database in a for-loop. // week is a moment-range object for (const day of week.by('day')) { // get start and end of day const startDay = day.startOf('day').toDate(); const endDay…
Luke
  • 185
  • 1
  • 3
  • 16
0
votes
1 answer

Calculate an array of Moment.js Ranges found in one array but not in another

Given the 2 arrays a and b containing moment ranges, const Moment = require('moment'); const MomentRange = require('moment-range'); const moment = MomentRange.extendMoment(Moment); let a = [ moment.range(moment('2020-01-01 09:00'),…
Nyxynyx
  • 61,411
  • 155
  • 482
  • 830
0
votes
1 answer

Managing moment.js range without timezones

I'm having problem with moment-range due to timezone! I get events from a database that return a string, e.g. start:"2019-02-08T12:30:00Z" end:"2019-02-08T13:30:00Z" When I put it inside fullcalendar v3 it will add my locale (GMT+1), it is shown…
TheEnigmist
  • 906
  • 1
  • 10
  • 23
0
votes
1 answer

Counting coverage of moment-range with multiple other ranges

I have a set of moment-range objects: a = range(2018-10-01 -> 2018-10-05) b = range(2018-10-10 -> 2018-10-15) c = range(2018-10-15 -> 2018-10-20) d = range(2018-10-21 -> 2018-10-25) So we have some adjacent ranges, but none that overlap. I also…
Shane Reustle
  • 8,633
  • 8
  • 40
  • 51
-1
votes
1 answer

Get all the start and the end dates of weeks of a year starting 2022 in moment

I want to get all the start and the end dates of weeks of a year starting 2022 in moment in YYYY-MM-DD (mysql) format. I want the end result to look something like this: [ ['2022-01-04', '2022-01-10'], ['2022-01-11', '2022-01-17'], …
Cedric Hadjian
  • 849
  • 12
  • 25