Giter VIP home page Giter VIP logo

Comments (5)

DeanKamali avatar DeanKamali commented on September 23, 2024 1

Hi,

I have created a function that dose that, if you are happy with my code, maybe it can be added to future release.

  let data = calendar().of(2017, 6);
  let weekdays = data.weekdays;
  let weeksInMonth = data.calendar;

  weeksInMonth.map((week, weekIndex) => {
    week.map((dayInWeek, dayInWeekIndex) => {
      if (dayInWeek != 0) {
        weekdays.map((day, dayIndex) => {
          if (dayInWeekIndex == dayIndex) {
            console.log(day, dayInWeek);
          }
        });
      }
    });
  });

output:

Saturday 1
Sunday 2
Monday 3
Tuesday 4
Wednesday 5
Thursday 6
Friday 7
Saturday 8
Sunday 9
Monday 10
Tuesday 11
Wednesday 12
Thursday 13
Friday 14
Saturday 15
Sunday 16
Monday 17
Tuesday 18
Wednesday 19
Thursday 20
Friday 21
Saturday 22
Sunday 23
Monday 24
Tuesday 25
Wednesday 26
Thursday 27
Friday 28
Saturday 29
Sunday 30
Monday 31

from calendar-js.

igor-ribeiro avatar igor-ribeiro commented on September 23, 2024 1

Hi, I can add a new property that contains the detailed info like that:

{
  calendarDetailed: [
    [
      { day: 1, weekday: 'Sunday', weekdayAbbr: 'Sun' },
      { day: 2, weekday: 'Monday', weekdayAbbr: 'Mon' },
      { day: 3, weekday: 'Tuesday', weekdayAbbr: 'Tue' },
      { day: 4, weekday: 'Wednesday', weekdayAbbr: 'Wed' },
      { day: 5, weekday: 'Thursday', weekdayAbbr: 'Thu' },
      { day: 6, weekday: 'Friday', weekdayAbbr: 'Fri' },
      { day: 7, weekday: 'Saturday', weekdayAbbr: 'Sat' }
    ],
    // The other weeks
  ],
}

What do you think?

from calendar-js.

DeanKamali avatar DeanKamali commented on September 23, 2024

Yeah that will be great! and heck a lot less code to put 👍

Here is even more twisted idea! would be nice to know in which week of the month that day is in.

{
  calendarDetailed: [
    [
      {  week: 0: day: 1, weekday: 'Sunday', weekdayAbbr: 'Sun' },
      {  week: 0: day: 2, weekday: 'Monday', weekdayAbbr: 'Mon' },
      {  week: 0: day: 3, weekday: 'Tuesday', weekdayAbbr: 'Tue' },
      {  week: 1: day: 4, weekday: 'Wednesday', weekdayAbbr: 'Wed' },
      {  week: 1: day: 5, weekday: 'Thursday', weekdayAbbr: 'Thu' },
      {  week: 2: day: 6, weekday: 'Friday', weekdayAbbr: 'Fri' },
      {  week: 3: day: 7, weekday: 'Saturday', weekdayAbbr: 'Sat' }
    ],
    // The other weeks
  ],
}

Thanks very much for this awesome library

from calendar-js.

igor-ribeiro avatar igor-ribeiro commented on September 23, 2024

Now you can pass a transformer function to the .of method to change the ouput, maybe it helps.

from calendar-js.

igor-ribeiro avatar igor-ribeiro commented on September 23, 2024

#7

from calendar-js.

Related Issues (15)

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.