Comments (5)
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.
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.
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.
Now you can pass a transformer function to the .of
method to change the ouput, maybe it helps.
from calendar-js.
from calendar-js.
Related Issues (15)
- calendar.of is not a function HOT 2
- Add the config options to the docs
- let's in index.js produces build errors in Vue + Webpack projects. HOT 1
- Make it browser friendly
- Error when doing unit test with Karma/PhanthomJS HOT 2
- Add day start week HOT 1
- bug in using 0 index for month in calendar().of(year, month) HOT 3
- Awesome stuff! HOT 1
- Is this still maintained/supported? HOT 1
- Wrong function type for generateCalendar HOT 1
- Disable certain days of the week HOT 2
- Displays different hour for some dates in month calendar
- a function to validate date HOT 3
- dealing with zero-index vs one-index of month HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from calendar-js.