@beyonk/date-utils
Advanced tools
Comparing version 4.0.1 to 4.1.0
@@ -5,2 +5,14 @@ { | ||
{ | ||
"version": "4.1.0", | ||
"tag": "@beyonk/date-utils_v4.1.0", | ||
"date": "Fri, 21 May 2021 08:40:10 GMT", | ||
"comments": { | ||
"minor": [ | ||
{ | ||
"comment": "add days of month method" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"version": "4.0.1", | ||
@@ -7,0 +19,0 @@ "tag": "@beyonk/date-utils_v4.0.1", |
# Change Log - @beyonk/date-utils | ||
This log was last generated on Wed, 12 May 2021 14:33:12 GMT and should not be manually modified. | ||
This log was last generated on Fri, 21 May 2021 08:40:10 GMT and should not be manually modified. | ||
## 4.1.0 | ||
Fri, 21 May 2021 08:40:10 GMT | ||
### Minor changes | ||
- add days of month method | ||
## 4.0.1 | ||
@@ -6,0 +13,0 @@ Wed, 12 May 2021 14:33:12 GMT |
@@ -102,2 +102,30 @@ import dayjs from 'dayjs/esm' | ||
function getMonthDays (displayedMonth) { | ||
const now = localDate() | ||
const requestedMonth = displayedMonth.startOf('month') | ||
const monthStart = requestedMonth.day() | ||
const daysInMonth = requestedMonth.daysInMonth() | ||
const calendarStart = requestedMonth.subtract(monthStart, 'days') | ||
const tailDays = 7 - (daysInMonth + monthStart) % 7 | ||
const totalDays = monthStart + daysInMonth + tailDays | ||
const days = {} | ||
for (let d = 0; d < totalDays; d++) { | ||
const date = calendarStart.add(d, 'days') | ||
const dateString = date.format('YYYY-MM-DD') | ||
days[dateString] = { | ||
valid: d >= monthStart && d - monthStart + 1 <= daysInMonth, | ||
date, | ||
year: date.year(), | ||
month: date.month() + 1, | ||
day: date.date(), | ||
dateString, | ||
number: date.format('DD'), | ||
isToday: date.isSame(now, 'day') | ||
} | ||
} | ||
return days | ||
} | ||
export { | ||
@@ -119,3 +147,4 @@ localDate, | ||
timeToMins, | ||
utcEquivalent | ||
utcEquivalent, | ||
getMonthDays | ||
} |
{ | ||
"name": "@beyonk/date-utils", | ||
"version": "4.0.1", | ||
"version": "4.1.0", | ||
"description": "Beyonk Date Utils", | ||
@@ -5,0 +5,0 @@ "author": "Antony Jones <aj@desirableobjects.co.uk>", |
8768
285