Giter VIP home page Giter VIP logo

moment-recur's People

Contributors

bramski avatar c-trimm avatar djui avatar ehacke avatar fampinheiro avatar jeffdupont avatar martijnwelker avatar niftylettuce avatar ntdb avatar ozum avatar rmarscher avatar scopevale avatar timhuff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

moment-recur's Issues

Interval 1 Month on Month with 29-31 days overjump month with lower days...

Hi,

there is an failure in the interval...

if i have a start date i.e. 2014-01-31 and an interval of 1 month
the next date is the 2014-03-31 so its not 1 month as except... its 2 month interval...

the correct interval must return the last day of the month if the next month will have a lower count of days...

Date format output

Moments is deprecating MM/DD/YYYY and other formats; details: moment/moment#1407

When passing the result of next dates occurence from .recur() moment-recur outputs date in MM/DD/YYYY which when passed back to moments is triggering the Date deprecation warning

Deprecation warning: moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.

The code I'm using to generate the next date array

var interval = moment.recur({
        start: start_date,
        end: end_date
    }).every( recurring_frequency ).days();
var nextdates = interval.fromDate( today_date ).next(1,"L");

then this is what triggers the warning
console.log( moment(nextdates[0]).format('YYYY-MM-DD') );

Recurrence pattern inconsistency (not producing expected dates)

I'd like to thank you for this very helpful library - it promises to make easy work of date recurrence, so I'm really hoping you can help me get past these issues.

I am able to create a pattern for day of month at any interval:

"every X month on the 16th"

r = moment(rr.start).recur(rr.until)
     .every(rr.interval, rr.frequency)
     .every(dom).dayOfMonth();

When I try to apply the same logic with the following patterns, the expected dates are not returned:

"every other Tuesday and Thursday"

r = moment(rr.start).recur(rr.until)
     .every(rr.interval, rr.frequency)
     .every(rr.dow).dayOfWeek();

"every X month on the 2nd Friday"

r = moment(rr.start).recur(rr.until)
     .every(rr.interval, rr.frequency)
     .every(dow).dayOfWeek()
     .every(wom).weeksOfMonthByDay();

Please let me know if you require further information to investigate this matter.
I look forward to your reply.

Best!

Every 2nd friday?

How do I generate a rule the returns every 2nd fridays?

moment("2017-05-01").recur("2017-05-31").every("friday").daysOfWeek().every(2).weeks();

produces no dates. Shouldn't it return May 5th and May 19th?

Question / feature request: missing some recurrence options

I like this lib very much!
...but, I also would like to set recurring events for:

  • Last day of the month (payday!)
  • 2nd monday in may (spring fair in our little village)
  • Easter monday (or Pentecost, Ascension day, other special days...)
  • offsets, like: 2 days before the last day of the month (could do Pentecost this way: 6 weeks after Easter)

or maybe some of these can be done already but I haven't found out how ?

ranges: daysOfWeek: Change a Calendar-Based Rule?

I am trying to change daysOfWeek rules. The source data I am working with uses 1-7.
But it's unclear how I can make this change. This is what I have so far, but the documentation is lacking details.

moment().recur({
    rules: [
        { units: { low: 1, high: 7 }, measure: "daysOfWeek" }
    ]
});

Non-ISO format used in NPM download

The version downloaded from NPM uses a non-ISO date (YYYY/MM/DD) at
https://github.com/c-trimm/moment-recur/blob/master/moment-recur.js#L737

This causes the moment warning: "Deprecation warning: value provided is not in a recognized ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.
Arguments"

master has the correct format of YYYY-MM-DD.

use with angular 2

Hi.
How can I install this in an angular2 app ?
I got momentjs working ( import * as moment from 'moment' ) but when I'm trying to import moment-recur (import 'moment-recur') I just get the error: Property 'recur' does not exist on type 'typeof moment'.
I installed both moment and moment-recur with npm.

Bower install moment-recur#1.0.5 provides old code

In the current (latest) version the moment.tz call in dateOnly is like this (which is correct)

    return moment.tz(this.format('YYYY-MM-DD'), 'UTC');

However, when you bower install you get an old version

    return moment.tz(this.format("YYYY/MM/DD"), "UTC");

which will throw a deprecation warning

1 Month interval starting on 28th Feb

I am seeing weird results when starting a 1 month interval on 28th Feb. The recurrence matches any date >= 28 and <= 31. For example:

var r =  moment.utc('2015-02-28T00:00:00.000Z').recur().every(1, 'month');
console.log(r.matches(moment.utc('2015-08-27T00:00:00Z'))); // false
console.log(r.matches(moment.utc('2015-08-28T00:00:00Z'))); // true
console.log(r.matches(moment.utc('2015-08-29T00:00:00Z'))); // true
console.log(r.matches(moment.utc('2015-08-30T00:00:00Z'))); // true
console.log(r.matches(moment.utc('2015-08-31T00:00:00Z'))); // true
console.log(r.matches(moment.utc('2015-09-01T00:00:00Z'))); // false

The same does not happen if the recurrence is started on 28th of a different month.

I have seen #4 but this seems like a different issue.

Why does npm postinstall run bower install?

It doesn't work with the way I'm trying to install this (in a docker container - bower can't be run as root and the docker container only has root). Why does it need bower?

Crash while running the following

I am trying to get an occurrence that starts say now, and occurs every two weeks on a Monday.
moment().recur().every('Monday').dayOfWeek().every(2).weeks().next(1,"L")

This crashes my app and I can't figure out a way of achieving what I want.

maintenance?

I'm using this library, and for the most part it's working good. It looks like maintenance is lagging though. Wondering who is running this now, and maybe should see about moving it to the https://github.com/moment owner?

Deprecation warning: months accessor is deprecated. Use month instead

Hello,

The code below from examples produces "Deprecation warning: months accessor is deprecated. Use month instead."

var valentines = moment().recur("2014-01-01", "2014-05-05").
    every(14).daysOfMonth().every("Februray").monthsOfYear();
    console.log(util.inspect(valentines.next(3, 'L')));

Best Regards,

Deprecation warning with moment.js 2.10.6

Using moment.js 2.10.6, deprecation messages are displayed using an example from the README.md. Specifically:

recurrence = moment("2014/01/01").recur().every(2).days();

Deprecation warning: moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to moment/moment#1407 for more info.
Error
at Function.createFromInputFallback (https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.js:746:36)
at configFromString (https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.js:826:32)
at configFromInput (https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.js:1353:13)
at prepareConfig (https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.js:1340:13)
at createFromConfig (https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.js:1307:44)
at createLocalOrUTC (https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.js:1385:16)
at local__createLocal (https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.js:1389:16)
at utils_hooks__hooks (https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.js:16:29)
at eval (eval at evaluate (unknown source), :1:14)
at Object.InjectedScript._evaluateOn (:904:55)

moment deprecation warning possibly originating from moment-recur

I'm not 100% sure, but, I believe this line (moment-recur.js:737):

return moment.tz(this.format('YYYY-MM-DD'), 'UTC');

Is causing this warning:

Deprecation warning: value provided is not in a recognized ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.

I think you want to do this:

return moment.tz(this.format('YYYY-MM-DDT00:00:00.000Z'), 'UTC');

or

return moment.tz(this.format('YYYY-MM-DD'), 'YYYY-MM-DD');

Clone

Method (literally or otherwise) to clone a moment recur object.

Find events for specific day / timeframe

Hi,

Great library!

I was wondering how a use case like this could be realised:

Say you have an event that is happening weekly. Now you want to view a specific day (in a calendar day view maybe) and see which events are happening on that day.

Or you want to list all events happening in the future.

As a dirty fix for now I fetch all events, generate the occurrences and then filter down. This works with a few events in a databse but obviously not with more.

Any ideas on that?

David

Node.js plugin

Why when I install the moment-recur I need install bower plugins?

Matching 4th weekday of month when recurrence started with 5th weekday of month

In Google Calendar, when you start a recurrence with let's say the 5th monday of a month, on the next month if there is only 4 mondays it will match the last one. I would expect this library to do the same.

Here's a test case scenario:

moment({ date: 31, month: 2, year: 2014 }) // 5th monday of march 2014
    .recur()
    .every(1).daysOfWeek() // monday
    .every(4) // fifth monday
    .weeksOfMonthByDay()
    .matches(moment({ date: 31, month: 7, year: 2015 })) // aug 31st 2015, 5th monday
    // returns true
moment({ date: 31, month: 2, year: 2014 }) // 5th monday of march 2014
    .recur()
    .every(1).daysOfWeek() // monday
    .every(4).weeksOfMonthByDay() // fifth monday
    .matches(moment({ date: 24, month: 10, year: 2014 })) // nov 24th 2014, 4th monday
    // returns false

Thank you

problem initializing moment-recur

Hello,

I have a problem initializing moment-recur.

TypeError: Object Wed Jan 01 2014 00:00:00 GMT+0100 has no method 'utcOffset'
at Moment.moment.fn.dateOnly (.../node_modules/moment-recur/moment-recur.js:745:81)

Maybe this is just a version mismatch (I still have a .zone() method available) ?

Versions used (in my package.json) :
"moment": "~2.5.1",
"moment-recur": "^1.0.5"

Please let me know if I did something wrong.

Update :
Running npm install --dev && gulp test gives the following output

$ gulp test
[12:23:53] Using gulpfile ...moment-recur/gulpfile.js
[12:23:53] Starting 'test'...
WARN [watcher]: Pattern "...moment-recur/bower_components/moment/moment.js" does not match any file.
WARN [watcher]: Pattern "...moment-recur/bower_components/moment-timezone/builds/moment-timezone-with-data.js" does not match any file.
INFO [karma]: Karma v0.12.35 server started at http://localhost:8080/
INFO [launcher]: Starting browser Chrome
WARN [web-server]: 404: /favicon.ico
INFO [Chromium 41.0.2272 (Ubuntu 0.0.0)]: Connected on socket MHC2liVo15IFgc3EzIJc with id 50993294
Chromium 41.0.2272 (Ubuntu 0.0.0) ERROR
  Uncaught Error: Can't find moment
  at ...node_modules/moment-recur/moment-recur.js:15


[12:24:08] 'test' errored after 14 s
[12:24:08] Error: 1
    at formatError (/usr/local/lib/node_modules/gulp/bin/gulp.js:169:10)
    at Gulp.<anonymous> (/usr/local/lib/node_modules/gulp/bin/gulp.js:195:15)
    at Gulp.emit (events.js:107:17)
    at Gulp.Orchestrator._emitTaskDone (...moment-recur/node_modules/gulp/node_modules/orchestrator/index.js:264:8)
    at ...node_modules/moment-recur/node_modules/gulp/node_modules/orchestrator/index.js:275:23
    at finish (...moment-recur/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:21:8)
    at cb (...node_modules/moment-recur/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:29:3)
    at removeAllListeners (...moment-recur/node_modules/karma/lib/server.js:218:7)
    at Server.<anonymous> (...node_modules/moment-recur/node_modules/karma/lib/server.js:229:9)
    at Server.g (events.js:199:16)

.next returns wrong dates

From the README.md I used this example:

// Create a recurrence
recurrence = moment("01/01/2014").recur().every(2).days();

// Generate the next three dates as moments
// Outputs: [moment("01/03/2014"), moment("01/05/2014"), moment("01/07/2014")]
nextDates = recurrence.next(3);

My outputs are:
// Outputs: [moment("01/02/2014"), moment("01/04/2014"), moment("01/06/2014")]

storing and quering

i saw in docs .save() function i understand thats the way to store but, to use only that then i cant do query in db side i would require to grab them all put in js and the do query so can you suggest anything?

.recur(string) and toISOString

ISO 8601 defines the string representation for Repeating Intervals.
See https://en.wikipedia.org/wiki/ISO_8601

It would be super useful to be able to create a recurrence using:
moment.recur(isoString)

and to serialize it back as
moment.recur(...).toISOString()

e.g.,

moment().recur().every(1).days().toISOString() => "R/2016-08-21/P1D"

Need ability to get number of intervals including start date

Love this library, thank you!
I have a case (which I'm not sure would be overly specific to me), where I need to be able to set a start date for an interval, setup necessary recurrence and then get the "next x" dates. I don't want to specify the end date (though we do take this value from the user, but it could be wrong, and the number of dates is always "correct").
For simplicity, let's say I want to do a weekly recurrence (in truth I can do weekly, fortnightly or monthly).

var startDate = "2015-02-25";
var intervals = moment(startDate).recur().every(1).week();
intervals.except(self.tournament().params.DatesNotPlayed());

I then run the following and store the resulting array somewhere for use later:

var allDates = intervals.next(numberOfRounds);

The result will be x dates where x is numberOfRounds. It DOESN'T include the start date, though, and I want it to.

I've tried using the .all() function but of course then I can't control how many dates I get, and if I use a user-defined "end" date, it may not end up in enough dates being generated.

A spanner in the works (I just realised I'm not doing this yet!) is that I still have to also implement it including the "day of week" to recur on, so e.g. every Wednesday weekly, every Wednesday fortnightly, or every Wednesday monthly. I'm imagining i would do this by first manipulating my start date to be the next Wednesday (or whatever day) after the given start date inclusive.

Is there any way of doing what I need to do now, or if not do you have any reason for it not being there? I can try to come up with a solution for it if you like, if you'd like to see it in there.

Not generating dates for 2017 (Next year of current date)

Hello, I have just started using this awesome plugin to generate some date lists with specific rules.
I am not sure whether I am doing something wrong or it is a bug.
So my problem is as follows:

var recurrence; recurrence = moment("2015-01-01").recur("2016-01-01").every(1, "months"); allDates = recurrence.all("YYYY-MM-DD"); console.log(allDates);

This returns the expected results (array length is 13).
But if I changed the start and end dates to: "2016-01-01" and "2017-01-01" the returning array is empty.

I also tried other notations and Options method along with days/weeks/months/years. Same result.
So we cannot calculate the dates for next year?
Or is it caused by something else? Maybe the date format? I used this format because the MM/DD/YYYY format in the examples are giving a deprecation warning.

Thanks in advance!

Recur.next ignores end date

Hi!

I guess this is intentional, but it should probably either be changed (could issue pull request) or pointed out in the README.

recurrence = moment("01/01/2014").recur().every(2).days();

recurrence.endDate("01/05/2014");

//is ["01/03/2014", "01/05/2014", "01/07/2014"], but expected ["01/03/2014", "01/05/2014"]
nextDates = recurrence.next(3, "L");

What do you think?

All best,
Matthias

suggestion for new features

Great job, Casey. This is just what Ive been looking for. Would it be possible to add new methods such as

1 count(start,end) would return the number of occurrences within the given range
2 last() would give the last occurrence (only available when end date is specified)
3 get(start,end) would return an array containing all occurrences within the given period. I suppose this could be done already by specifying a from and end date and using the all() method?

one final thought. is it possible to turn off the console.logging of all Match results?

Is anyone actively monitoring this repo?

I find this to be a very versatile and useful moment plugin. I see Issues and PRs that have been lingering without resolution.

For those who have the ability to merge... are you still active here?

For others, have you found an alternative that meets your date recurrence needs?

Support for hours, minutes, seconds

May I know why time is not supported? As I would like to do:

var recurrence = moment().recur("01/01/2014", "01/07/2014").every(15).minutes();

I would like to contribute if necessary. Thank you.

Every Other Week With Specific Start Date

I would like to setup a recurring schedule of "every 2 weeks" starting on a specific date.

For example, suppose a schedule that starts on Tuesday, 2016-01-12 that should recur every Tuesday every other week. What is the next scheduled date after 2016-02-01? It should be 2016-02-09 (4 weeks after 2016-01-12). But the following code returns 2016-02-02.

var later = require("later");

var startDate = new Date("2016-01-12");
var fromDate = new Date("2016-02-01");

recur = later.parse.recur();

recur.every(2).weekOfYear().on([3]).dayOfWeek();

console.log(later.schedule(recur).next(1, fromDate));

So it seems later is always assuming the schedule starts on the 1st week of the year?

Please advise.

Thanks!
Steve

Falsely matching recurring days

When I want to match a day with e.g. the last day of a month that has only 30 days, the method "matches" will return a false "true"

const rc = moment("2017-04-30").recur().every(1,"months");
console.log(rc.matches("05/30/2017")); //true
console.log(rc.matches("05/31/2017")); //true

Is this a bug? Or am I doing something wrong here? This is only happening, if the recurring start date is the last of a 30 day month or if we choose the last of February and match it with any other day of the month higher than 28.

rrule converter

Do you have any plans on this?

moment-recur to rrule and back

Is it possible to set maximum count of repeats?

Let's say I have rule that says:

Every 20th day of the month that is Monday and I want recur to have start only and to automatically set end date so there would be 10 occurrences of event.

Is it possible?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.