Skip to content

Commit

Permalink
Release v2.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
uvarov-frontend committed Nov 6, 2022
1 parent eddc12a commit fd5714e
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build/vanilla-calendar.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@uvarov.frontend/vanilla-calendar",
"version": "2.1.4",
"version": "2.1.5",
"description": "Vanilla JS calendar without using additional packages. A lightweight date and time picker written in pure JavaScript using TypeScript.",
"homepage": "https://vanilla-calendar.frontend.uvarov.tech/",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/methods/createDays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const createDays = (self: IVanillaCalendar) => {
dayBtnEl.dataset.calendarDay = date;

if (self.settings.visibility.weekNumbers) {
const weekNumber = getWeekNumber(date);
const weekNumber = getWeekNumber(date, self.settings.iso8601);
if (!weekNumber) return;
dayBtnEl.dataset.calendarWeekNumber = `${weekNumber.week}`;
}
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/methods/createWeekNumbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const createWeekNumbers = (self: IVanillaCalendar, firstDayWeek: number, daysSel
weekNumbersEl.innerHTML = '';

for (let i = 0; i < countWeek; i++) {
const weekNumber = getWeekNumber(daysBtnEl[i * 7].dataset.calendarDay);
const weekNumber = getWeekNumber(daysBtnEl[i * 7].dataset.calendarDay, self.settings.iso8601);
if (!weekNumber) return;

const weekNumberEl = templateWeekNumberEl.cloneNode(true);
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/methods/getWeekNumber.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const getWeekNumber = (date: string | undefined) => {
const getWeekNumber = (date: string | undefined, iso8601: boolean) => {
if (!date) return null;
const day = new Date(date).getUTCDate();
const month = new Date(date).getUTCMonth();
const year = new Date(date).getUTCFullYear();
const correctDate = new Date(year, month, day);
const yearStart = new Date(Date.UTC(correctDate.getUTCFullYear(), 0, 1));
const yearStart = new Date(Date.UTC(correctDate.getUTCFullYear(), 0, iso8601 ? 1 : 0));
const weekNumber = Math.ceil(((((+correctDate) - (+yearStart)) / 86400000) - 1) / 7);

return {
Expand Down

0 comments on commit fd5714e

Please sign in to comment.