Giter Site home page Giter Site logo

Exceptions about moment-recur HOT 3 OPEN

ZweisteinT avatar ZweisteinT commented on September 5, 2024
Exceptions

from moment-recur.

Comments (3)

c-trimm avatar c-trimm commented on September 5, 2024

What format are the dates in the exception array in? If they do not contain time information set to 0:00:00, then they will not match correctly, and therefore not be considered an exception.

Note: It's not recommended to create a recurrence using that format - usually you would only do so when importing rules that were exported with the export function.

Also, we should add support for passing arrays to the except function, as well as ensuring that the isException function removes any time information from its dates before trying to match them.

from moment-recur.

ZweisteinT avatar ZweisteinT commented on September 5, 2024

Its not my code. Previous developer seems to have written the following code:

var Uc = '"' + moment(jc[Z], "DD.MM.YYYY").format("MM/DD/YYYY") + '"';
Oc.push(Uc);
Fc = moment().recur({
                            start: Hc,
                            end: Cc,
                            rules: [{
                                units: {
                                    1: !0
                                },
                                measure: "days"
                            }],
                            exceptions: Oc
})

what format is needed for exceptions?
Maybe he tried copying your example from your github start page, which is also without time:


moment().recur({
    start: "01/01/2014",
    end: "12/31/2014",
    rules: [
        { units: {  2 : true }, measure: "days" }
    ],
    exceptions: ["01/05/2014"]
});

from moment-recur.

c-trimm avatar c-trimm commented on September 5, 2024

I apologize, it's been a little while since I've worked deeply on this project; my last comment is untrue - moment-recur is already stripping the time information away from exception dates, so that would not be the issue.

It's hard to say what your issue is without an example using some actual dates that are being passed. I've tested my example and it skips 01/05/2014 as expected, so nothing appears to be broken. I've attempted to recreate the code you provided with some actual values and run it, and it still works as expected: https://jsfiddle.net/22tq3d3r/

Also note, for Uc, there is no reason to format the moment and convert it to a string - you can simply pass the moment moment(jc[Z], "DD.MM.YYYY") inside of an array to exceptions:
exceptions: [moment(jc[Z], "DD.MM.YYYY")].

from moment-recur.

Related Issues (20)

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.