Richardsl/heatmap-calendar-obsidian

Year is incorrectly rendered

asphaltbuffet opened this issue · 6 comments

Choosing 2022 as the year for a calendar is showing the wrong calendar. It looks like Jan 1, 2022 starts on a Friday when it should be starting on a Saturday:

Rendered:
image

Markdown:

### `ris:Zzz` Sleep `ris:Zzz`
```dataviewjs
const calendarData = { 
	year: 2022 , 
	colors: {   // optional, defaults to first value
	  blue:        ["#8cb9ff","#69a3ff","#428bff","#1872ff","#0058e2"], // this first entry is considered default
	  green:       ["#c6e48b","#7bc96f","#49af5d","#2e8840","#196127"],
	  red:         ["#ff9e82","#ff7b55","#ff4d1a","#e73400","#bd2a00"],
	  orange:      ["#ffa244","#fd7f00","#dd6f00","#bf6000","#9b4e00"],
	  pink:        ["#ff96cb","#ff70b8","#ff3a9d","#ee0077","#c30062"],
	  orangeToRed: ["#ffdf04","#ffbe04","#ff9a03","#ff6d02","#ff2c01"]
	},
	entries: [] // populated in the DataviewJS loop below
}

for(let page of dv.pages('"periodic-notes/daily"').where(p=>p.tracking.sleep).sort(p=>p.date)){ //DataviewJS stuff

	calendarData.entries.push({
		date: moment(page.file.name, 'YYYY.MM.DD - ddd').format('YYYY-MM-DD'),
		intensity: moment.duration(page.tracking.sleep, 'hours').asHours(), // optional, what color intensity to use for entry, will autoscale. Default 4 (1-5)
		content: moment(page.file.name, 'YYYY.MM.DD - ddd').format('DD'),
		color: "blue", // optional, reference from your colors object. If no color is supplied; colors[0] is used
	})

}

/**
* param1  HTMLElement   this gives the plugin a reference to render the calendar at
* param2  CalendarData  your calendar object, with settings/data for the calendar
*/
renderHeatmapCalendar(this.container, calendarData)

``` 

Obsidian: v0.13.33
OS: Windows 10
Heatmap Calendar: v0.1.0

I see the same thing on my end as well:

image

Will take a look at this tonight. Are you guys US based?

Thanks for letting me know guys, this was a major bug.
The problem was me using Date.getDay(), when instead i should have used Date.getUTCDay().

I have released a new version now, please go to obsidian settings to update the plugin

Looks great! Thanks!

perfect! thank you for the quick turnaround. Works great.

Thanks! This works for me!