generate-calendar

    1.0.0 • Public • Published

    generate-calendar

    A lib to generate calendar data

    Install

     yarn add generate-calendar
     or
     npm install generate-calendar
    

    How to use

    import { generateCalendar } from "generate-calendar";
    
    let date = new Date();
    
    const data = generateCalendar(date);
    console.log(data);
    /*
    [
      [
        {
          "days": [
            "2021-12-31T16:00:00.000Z"
          ],
          "week": 52
        },
        {
          "days": [
            "2022-01-01T16:00:00.000Z",
            "2022-01-02T16:00:00.000Z",
            "2022-01-03T16:00:00.000Z",
            "2022-01-04T16:00:00.000Z",
            "2022-01-05T16:00:00.000Z",
            "2022-01-06T16:00:00.000Z",
            "2022-01-07T16:00:00.000Z"
          ],
          "week": 1
        },
        {
          "days": [
            "2022-01-08T16:00:00.000Z",
            "2022-01-09T16:00:00.000Z",
            "2022-01-10T16:00:00.000Z",
            "2022-01-11T16:00:00.000Z",
            "2022-01-12T16:00:00.000Z",
            "2022-01-13T16:00:00.000Z",
            "2022-01-14T16:00:00.000Z"
          ],
          "week": 2
        },
        {
          "days": [
            "2022-01-15T16:00:00.000Z",
            "2022-01-16T16:00:00.000Z",
            "2022-01-17T16:00:00.000Z",
            "2022-01-18T16:00:00.000Z",
            "2022-01-19T16:00:00.000Z",
            "2022-01-20T16:00:00.000Z",
            "2022-01-21T16:00:00.000Z"
          ],
          "week": 3
        },
        {
          "days": [
            "2022-01-22T16:00:00.000Z",
            "2022-01-23T16:00:00.000Z",
            "2022-01-24T16:00:00.000Z",
            "2022-01-25T16:00:00.000Z",
            "2022-01-26T16:00:00.000Z",
            "2022-01-27T16:00:00.000Z",
            "2022-01-28T16:00:00.000Z"
          ],
          "week": 4
        },
        {
          "days": [
            "2022-01-29T16:00:00.000Z",
            "2022-01-30T16:00:00.000Z"
          ],
          "week": 5
        }
      ],
      [
        {
          "days": [
            "2022-01-31T16:00:00.000Z",
            "2022-02-01T16:00:00.000Z",
            "2022-02-02T16:00:00.000Z",
            "2022-02-03T16:00:00.000Z",
            "2022-02-04T16:00:00.000Z"
          ],
          "week": 5
        },
        {
          "days": [
            "2022-02-05T16:00:00.000Z",
            "2022-02-06T16:00:00.000Z",
            "2022-02-07T16:00:00.000Z",
            "2022-02-08T16:00:00.000Z",
            "2022-02-09T16:00:00.000Z",
            "2022-02-10T16:00:00.000Z",
            "2022-02-11T16:00:00.000Z"
          ],
          "week": 6
        },
        {
          "days": [
            "2022-02-12T16:00:00.000Z",
            "2022-02-13T16:00:00.000Z",
            "2022-02-14T16:00:00.000Z",
            "2022-02-15T16:00:00.000Z",
            "2022-02-16T16:00:00.000Z",
            "2022-02-17T16:00:00.000Z",
            "2022-02-18T16:00:00.000Z"
          ],
          "week": 7
        },
        {
          "days": [
            "2022-02-19T16:00:00.000Z",
            "2022-02-20T16:00:00.000Z",
            "2022-02-21T16:00:00.000Z",
            "2022-02-22T16:00:00.000Z",
            "2022-02-23T16:00:00.000Z",
            "2022-02-24T16:00:00.000Z",
            "2022-02-25T16:00:00.000Z"
          ],
          "week": 8
        },
        {
          "days": [
            "2022-02-26T16:00:00.000Z",
            "2022-02-27T16:00:00.000Z"
          ],
          "week": 9
        }
      ],
      [
        {
          "days": [
            "2022-02-28T16:00:00.000Z",
            "2022-03-01T16:00:00.000Z",
            "2022-03-02T16:00:00.000Z",
            "2022-03-03T16:00:00.000Z",
            "2022-03-04T16:00:00.000Z"
          ],
          "week": 9
        },
        {
          "days": [
            "2022-03-05T16:00:00.000Z",
            "2022-03-06T16:00:00.000Z",
            "2022-03-07T16:00:00.000Z",
            "2022-03-08T16:00:00.000Z",
            "2022-03-09T16:00:00.000Z",
            "2022-03-10T16:00:00.000Z",
            "2022-03-11T16:00:00.000Z"
          ],
          "week": 10
        },
        {
          "days": [
            "2022-03-12T16:00:00.000Z",
            "2022-03-13T16:00:00.000Z",
            "2022-03-14T16:00:00.000Z",
            "2022-03-15T16:00:00.000Z",
            "2022-03-16T16:00:00.000Z",
            "2022-03-17T16:00:00.000Z",
            "2022-03-18T16:00:00.000Z"
          ],
          "week": 11
        },
        {
          "days": [
            "2022-03-19T16:00:00.000Z",
            "2022-03-20T16:00:00.000Z",
            "2022-03-21T16:00:00.000Z",
            "2022-03-22T16:00:00.000Z",
            "2022-03-23T16:00:00.000Z",
            "2022-03-24T16:00:00.000Z",
            "2022-03-25T16:00:00.000Z"
          ],
          "week": 12
        },
        {
          "days": [
            "2022-03-26T16:00:00.000Z",
            "2022-03-27T16:00:00.000Z",
            "2022-03-28T16:00:00.000Z",
            "2022-03-29T16:00:00.000Z",
            "2022-03-30T16:00:00.000Z"
          ],
          "week": 13
        }
      ],
      [
        {
          "days": [
            "2022-03-31T16:00:00.000Z",
            "2022-04-01T16:00:00.000Z"
          ],
          "week": 13
        },
        {
          "days": [
            "2022-04-02T16:00:00.000Z",
            "2022-04-03T16:00:00.000Z",
            "2022-04-04T16:00:00.000Z",
            "2022-04-05T16:00:00.000Z",
            "2022-04-06T16:00:00.000Z",
            "2022-04-07T16:00:00.000Z",
            "2022-04-08T16:00:00.000Z"
          ],
          "week": 14
        },
        {
          "days": [
            "2022-04-09T16:00:00.000Z",
            "2022-04-10T16:00:00.000Z",
            "2022-04-11T16:00:00.000Z",
            "2022-04-12T16:00:00.000Z",
            "2022-04-13T16:00:00.000Z",
            "2022-04-14T16:00:00.000Z",
            "2022-04-15T16:00:00.000Z"
          ],
          "week": 15
        },
        {
          "days": [
            "2022-04-16T16:00:00.000Z",
            "2022-04-17T16:00:00.000Z",
            "2022-04-18T16:00:00.000Z",
            "2022-04-19T16:00:00.000Z",
            "2022-04-20T16:00:00.000Z",
            "2022-04-21T16:00:00.000Z",
            "2022-04-22T16:00:00.000Z"
          ],
          "week": 16
        },
        {
          "days": [
            "2022-04-23T16:00:00.000Z",
            "2022-04-24T16:00:00.000Z",
            "2022-04-25T16:00:00.000Z",
            "2022-04-26T16:00:00.000Z",
            "2022-04-27T16:00:00.000Z",
            "2022-04-28T16:00:00.000Z",
            "2022-04-29T16:00:00.000Z"
          ],
          "week": 17
        }
      ],
      [
        {
          "days": [
            "2022-04-30T16:00:00.000Z",
            "2022-05-01T16:00:00.000Z",
            "2022-05-02T16:00:00.000Z",
            "2022-05-03T16:00:00.000Z",
            "2022-05-04T16:00:00.000Z",
            "2022-05-05T16:00:00.000Z",
            "2022-05-06T16:00:00.000Z"
          ],
          "week": 18
        },
        {
          "days": [
            "2022-05-07T16:00:00.000Z",
            "2022-05-08T16:00:00.000Z",
            "2022-05-09T16:00:00.000Z",
            "2022-05-10T16:00:00.000Z",
            "2022-05-11T16:00:00.000Z",
            "2022-05-12T16:00:00.000Z",
            "2022-05-13T16:00:00.000Z"
          ],
          "week": 19
        },
        {
          "days": [
            "2022-05-14T16:00:00.000Z",
            "2022-05-15T16:00:00.000Z",
            "2022-05-16T16:00:00.000Z",
            "2022-05-17T16:00:00.000Z",
            "2022-05-18T16:00:00.000Z",
            "2022-05-19T16:00:00.000Z",
            "2022-05-20T16:00:00.000Z"
          ],
          "week": 20
        },
        {
          "days": [
            "2022-05-21T16:00:00.000Z",
            "2022-05-22T16:00:00.000Z",
            "2022-05-23T16:00:00.000Z",
            "2022-05-24T16:00:00.000Z",
            "2022-05-25T16:00:00.000Z",
            "2022-05-26T16:00:00.000Z",
            "2022-05-27T16:00:00.000Z"
          ],
          "week": 21
        },
        {
          "days": [
            "2022-05-28T16:00:00.000Z",
            "2022-05-29T16:00:00.000Z",
            "2022-05-30T16:00:00.000Z"
          ],
          "week": 22
        }
      ],
      [
        {
          "days": [
            "2022-05-31T16:00:00.000Z",
            "2022-06-01T16:00:00.000Z",
            "2022-06-02T16:00:00.000Z",
            "2022-06-03T16:00:00.000Z"
          ],
          "week": 22
        },
        {
          "days": [
            "2022-06-04T16:00:00.000Z",
            "2022-06-05T16:00:00.000Z",
            "2022-06-06T16:00:00.000Z",
            "2022-06-07T16:00:00.000Z",
            "2022-06-08T16:00:00.000Z",
            "2022-06-09T16:00:00.000Z",
            "2022-06-10T16:00:00.000Z"
          ],
          "week": 23
        },
        {
          "days": [
            "2022-06-11T16:00:00.000Z",
            "2022-06-12T16:00:00.000Z",
            "2022-06-13T16:00:00.000Z",
            "2022-06-14T16:00:00.000Z",
            "2022-06-15T16:00:00.000Z",
            "2022-06-16T16:00:00.000Z",
            "2022-06-17T16:00:00.000Z"
          ],
          "week": 24
        },
        {
          "days": [
            "2022-06-18T16:00:00.000Z",
            "2022-06-19T16:00:00.000Z",
            "2022-06-20T16:00:00.000Z",
            "2022-06-21T16:00:00.000Z",
            "2022-06-22T16:00:00.000Z",
            "2022-06-23T16:00:00.000Z",
            "2022-06-24T16:00:00.000Z"
          ],
          "week": 25
        },
        {
          "days": [
            "2022-06-25T16:00:00.000Z",
            "2022-06-26T16:00:00.000Z",
            "2022-06-27T16:00:00.000Z",
            "2022-06-28T16:00:00.000Z",
            "2022-06-29T16:00:00.000Z"
          ],
          "week": 26
        }
      ],
      [
        {
          "days": [
            "2022-06-30T16:00:00.000Z",
            "2022-07-01T16:00:00.000Z"
          ],
          "week": 26
        },
        {
          "days": [
            "2022-07-02T16:00:00.000Z",
            "2022-07-03T16:00:00.000Z",
            "2022-07-04T16:00:00.000Z",
            "2022-07-05T16:00:00.000Z",
            "2022-07-06T16:00:00.000Z",
            "2022-07-07T16:00:00.000Z",
            "2022-07-08T16:00:00.000Z"
          ],
          "week": 27
        },
        {
          "days": [
            "2022-07-09T16:00:00.000Z",
            "2022-07-10T16:00:00.000Z",
            "2022-07-11T16:00:00.000Z",
            "2022-07-12T16:00:00.000Z",
            "2022-07-13T16:00:00.000Z",
            "2022-07-14T16:00:00.000Z",
            "2022-07-15T16:00:00.000Z"
          ],
          "week": 28
        },
        {
          "days": [
            "2022-07-16T16:00:00.000Z",
            "2022-07-17T16:00:00.000Z",
            "2022-07-18T16:00:00.000Z",
            "2022-07-19T16:00:00.000Z",
            "2022-07-20T16:00:00.000Z",
            "2022-07-21T16:00:00.000Z",
            "2022-07-22T16:00:00.000Z"
          ],
          "week": 29
        },
        {
          "days": [
            "2022-07-23T16:00:00.000Z",
            "2022-07-24T16:00:00.000Z",
            "2022-07-25T16:00:00.000Z",
            "2022-07-26T16:00:00.000Z",
            "2022-07-27T16:00:00.000Z",
            "2022-07-28T16:00:00.000Z",
            "2022-07-29T16:00:00.000Z"
          ],
          "week": 30
        },
        {
          "days": [
            "2022-07-30T16:00:00.000Z"
          ],
          "week": 31
        }
      ],
      [
        {
          "days": [
            "2022-07-31T16:00:00.000Z",
            "2022-08-01T16:00:00.000Z",
            "2022-08-02T16:00:00.000Z",
            "2022-08-03T16:00:00.000Z",
            "2022-08-04T16:00:00.000Z",
            "2022-08-05T16:00:00.000Z"
          ],
          "week": 31
        },
        {
          "days": [
            "2022-08-06T16:00:00.000Z",
            "2022-08-07T16:00:00.000Z",
            "2022-08-08T16:00:00.000Z",
            "2022-08-09T16:00:00.000Z",
            "2022-08-10T16:00:00.000Z",
            "2022-08-11T16:00:00.000Z",
            "2022-08-12T16:00:00.000Z"
          ],
          "week": 32
        },
        {
          "days": [
            "2022-08-13T16:00:00.000Z",
            "2022-08-14T16:00:00.000Z",
            "2022-08-15T16:00:00.000Z",
            "2022-08-16T16:00:00.000Z",
            "2022-08-17T16:00:00.000Z",
            "2022-08-18T16:00:00.000Z",
            "2022-08-19T16:00:00.000Z"
          ],
          "week": 33
        },
        {
          "days": [
            "2022-08-20T16:00:00.000Z",
            "2022-08-21T16:00:00.000Z",
            "2022-08-22T16:00:00.000Z",
            "2022-08-23T16:00:00.000Z",
            "2022-08-24T16:00:00.000Z",
            "2022-08-25T16:00:00.000Z",
            "2022-08-26T16:00:00.000Z"
          ],
          "week": 34
        },
        {
          "days": [
            "2022-08-27T16:00:00.000Z",
            "2022-08-28T16:00:00.000Z",
            "2022-08-29T16:00:00.000Z",
            "2022-08-30T16:00:00.000Z"
          ],
          "week": 35
        }
      ],
      [
        {
          "days": [
            "2022-08-31T16:00:00.000Z",
            "2022-09-01T16:00:00.000Z",
            "2022-09-02T16:00:00.000Z"
          ],
          "week": 35
        },
        {
          "days": [
            "2022-09-03T16:00:00.000Z",
            "2022-09-04T16:00:00.000Z",
            "2022-09-05T16:00:00.000Z",
            "2022-09-06T16:00:00.000Z",
            "2022-09-07T16:00:00.000Z",
            "2022-09-08T16:00:00.000Z",
            "2022-09-09T16:00:00.000Z"
          ],
          "week": 36
        },
        {
          "days": [
            "2022-09-10T16:00:00.000Z",
            "2022-09-11T16:00:00.000Z",
            "2022-09-12T16:00:00.000Z",
            "2022-09-13T16:00:00.000Z",
            "2022-09-14T16:00:00.000Z",
            "2022-09-15T16:00:00.000Z",
            "2022-09-16T16:00:00.000Z"
          ],
          "week": 37
        },
        {
          "days": [
            "2022-09-17T16:00:00.000Z",
            "2022-09-18T16:00:00.000Z",
            "2022-09-19T16:00:00.000Z",
            "2022-09-20T16:00:00.000Z",
            "2022-09-21T16:00:00.000Z",
            "2022-09-22T16:00:00.000Z",
            "2022-09-23T16:00:00.000Z"
          ],
          "week": 38
        },
        {
          "days": [
            "2022-09-24T16:00:00.000Z",
            "2022-09-25T16:00:00.000Z",
            "2022-09-26T16:00:00.000Z",
            "2022-09-27T16:00:00.000Z",
            "2022-09-28T16:00:00.000Z",
            "2022-09-29T16:00:00.000Z"
          ],
          "week": 39
        }
      ],
      [
        {
          "days": [
            "2022-09-30T16:00:00.000Z"
          ],
          "week": 39
        },
        {
          "days": [
            "2022-10-01T16:00:00.000Z",
            "2022-10-02T16:00:00.000Z",
            "2022-10-03T16:00:00.000Z",
            "2022-10-04T16:00:00.000Z",
            "2022-10-05T16:00:00.000Z",
            "2022-10-06T16:00:00.000Z",
            "2022-10-07T16:00:00.000Z"
          ],
          "week": 40
        },
        {
          "days": [
            "2022-10-08T16:00:00.000Z",
            "2022-10-09T16:00:00.000Z",
            "2022-10-10T16:00:00.000Z",
            "2022-10-11T16:00:00.000Z",
            "2022-10-12T16:00:00.000Z",
            "2022-10-13T16:00:00.000Z",
            "2022-10-14T16:00:00.000Z"
          ],
          "week": 41
        },
        {
          "days": [
            "2022-10-15T16:00:00.000Z",
            "2022-10-16T16:00:00.000Z",
            "2022-10-17T16:00:00.000Z",
            "2022-10-18T16:00:00.000Z",
            "2022-10-19T16:00:00.000Z",
            "2022-10-20T16:00:00.000Z",
            "2022-10-21T16:00:00.000Z"
          ],
          "week": 42
        },
        {
          "days": [
            "2022-10-22T16:00:00.000Z",
            "2022-10-23T16:00:00.000Z",
            "2022-10-24T16:00:00.000Z",
            "2022-10-25T16:00:00.000Z",
            "2022-10-26T16:00:00.000Z",
            "2022-10-27T16:00:00.000Z",
            "2022-10-28T16:00:00.000Z"
          ],
          "week": 43
        },
        {
          "days": [
            "2022-10-29T16:00:00.000Z",
            "2022-10-30T16:00:00.000Z"
          ],
          "week": 44
        }
      ],
      [
        {
          "days": [
            "2022-10-31T16:00:00.000Z",
            "2022-11-01T16:00:00.000Z",
            "2022-11-02T16:00:00.000Z",
            "2022-11-03T16:00:00.000Z",
            "2022-11-04T16:00:00.000Z"
          ],
          "week": 44
        },
        {
          "days": [
            "2022-11-05T16:00:00.000Z",
            "2022-11-06T16:00:00.000Z",
            "2022-11-07T16:00:00.000Z",
            "2022-11-08T16:00:00.000Z",
            "2022-11-09T16:00:00.000Z",
            "2022-11-10T16:00:00.000Z",
            "2022-11-11T16:00:00.000Z"
          ],
          "week": 45
        },
        {
          "days": [
            "2022-11-12T16:00:00.000Z",
            "2022-11-13T16:00:00.000Z",
            "2022-11-14T16:00:00.000Z",
            "2022-11-15T16:00:00.000Z",
            "2022-11-16T16:00:00.000Z",
            "2022-11-17T16:00:00.000Z",
            "2022-11-18T16:00:00.000Z"
          ],
          "week": 46
        },
        {
          "days": [
            "2022-11-19T16:00:00.000Z",
            "2022-11-20T16:00:00.000Z",
            "2022-11-21T16:00:00.000Z",
            "2022-11-22T16:00:00.000Z",
            "2022-11-23T16:00:00.000Z",
            "2022-11-24T16:00:00.000Z",
            "2022-11-25T16:00:00.000Z"
          ],
          "week": 47
        },
        {
          "days": [
            "2022-11-26T16:00:00.000Z",
            "2022-11-27T16:00:00.000Z",
            "2022-11-28T16:00:00.000Z",
            "2022-11-29T16:00:00.000Z"
          ],
          "week": 48
        }
      ],
      [
        {
          "days": [
            "2022-11-30T16:00:00.000Z",
            "2022-12-01T16:00:00.000Z",
            "2022-12-02T16:00:00.000Z"
          ],
          "week": 48
        },
        {
          "days": [
            "2022-12-03T16:00:00.000Z",
            "2022-12-04T16:00:00.000Z",
            "2022-12-05T16:00:00.000Z",
            "2022-12-06T16:00:00.000Z",
            "2022-12-07T16:00:00.000Z",
            "2022-12-08T16:00:00.000Z",
            "2022-12-09T16:00:00.000Z"
          ],
          "week": 49
        },
        {
          "days": [
            "2022-12-10T16:00:00.000Z",
            "2022-12-11T16:00:00.000Z",
            "2022-12-12T16:00:00.000Z",
            "2022-12-13T16:00:00.000Z",
            "2022-12-14T16:00:00.000Z",
            "2022-12-15T16:00:00.000Z",
            "2022-12-16T16:00:00.000Z"
          ],
          "week": 50
        },
        {
          "days": [
            "2022-12-17T16:00:00.000Z",
            "2022-12-18T16:00:00.000Z",
            "2022-12-19T16:00:00.000Z",
            "2022-12-20T16:00:00.000Z",
            "2022-12-21T16:00:00.000Z",
            "2022-12-22T16:00:00.000Z",
            "2022-12-23T16:00:00.000Z"
          ],
          "week": 51
        },
        {
          "days": [
            "2022-12-24T16:00:00.000Z",
            "2022-12-25T16:00:00.000Z",
            "2022-12-26T16:00:00.000Z",
            "2022-12-27T16:00:00.000Z",
            "2022-12-28T16:00:00.000Z",
            "2022-12-29T16:00:00.000Z",
            "2022-12-30T16:00:00.000Z"
          ],
          "week": 52
        }
      ]
    ]
    
    
     */

    Keywords

    none

    Install

    npm i generate-calendar

    DownloadsWeekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    18.9 kB

    Total Files

    3

    Last publish

    Collaborators

    • fizwen