Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Year is incorrectly rendered #4

Closed
asphaltbuffet opened this issue Mar 17, 2022 · 6 comments
Closed

Year is incorrectly rendered #4

asphaltbuffet opened this issue Mar 17, 2022 · 6 comments

Comments

@asphaltbuffet
Copy link

asphaltbuffet commented Mar 17, 2022

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

@ebdavison
Copy link

I see the same thing on my end as well:

image

@Richardsl
Copy link
Owner

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

@Richardsl
Copy link
Owner

Richardsl commented Mar 18, 2022

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

@asphaltbuffet
Copy link
Author

Looks great! Thanks!

@ebdavison
Copy link

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

@tdog123
Copy link

tdog123 commented Mar 21, 2022

Thanks! This works for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants