Richardsl / heatmap-calendar-obsidian

An Obsidian plugin for displaying data in a calendar similar to the github activity calendar
Apache License 2.0
623 stars 103 forks source link

Not working with 2023? #57

Open fonky415 opened 1 year ago

fonky415 commented 1 year ago

Calendar continues to show 2022 days. Do I need to do something to switch to 2023?

Screenshot 2023-01-02 at 12 11 30 AM
slillig commented 1 year ago

Getting same when changing year to year: 2023 from the examples.

Richardsl commented 1 year ago

Do you have the year variable set in your code? If you remove it completely, it should default to the current year

fonky415 commented 1 year ago

This is the code:

`dataviewjs

dv.span("Mood (1-10)")

const hue1 = 13 const hue2 = 132

const calendarData= { intensityScaleStart: 1, intensityScaleEnd: 9, colors: { red2green: [ hsl(${hue1}, 100%, 37%), // 1 - darkest red hsl(${hue1}, 100%, 50%), // 2 - hsl(${hue1}, 100%, 60%), // 3 - hsl(${hue1}, 100%, 77%), // 4 - lightest red hsl(${hue1}, 100%, 90%), // 5 - neutral gray hsl(${hue2*0.7}, 70%, 72%), // 6 - lightest green hsl(${hue2*0.85}, 43%, 56%), // 7 - hsl(${hue2}, 49%, 36%), // 8 - hsl(${hue2}, 59%, 24%), // 9 - darkest green ], }, entries: [] }

for(let page of dv.pages('"Life/Journal/2023/Daily"').where(p=>p.mood)){

calendarData.entries.push({
    date: page.file.name,
    intensity: page.mood,
    content: await dv.span(`[](${page.file.name})`),
    })

}

renderHeatmapCalendar(this.container, calendarData) `

I just copied and pasted the thing from the example vault because I was too lazy to learn how to make it. 2022 worked fined for me. I can't find any variable with 2023.

slillig commented 1 year ago

I originally tried to update the year to 2023 but removing the year: variable altogether seems to be working now.

maskedmage77 commented 1 year ago

It seems to be an issue with the Timezone of the user when the code runs

new Date(e.date).getFullYear()

on line 84 of main.ts. It looks like the easiest way to fix this issue is to add T00:00 to e.date when the date is created.