Published
Edited
Oct 12, 2021
Importers
Insert cell
Insert cell
### Permet d'avoir tous les jours entre une date et une autre (non utilisé : side note)
Insert cell
Date.prototype.addDays = function(days) {
var date = new Date(this.valueOf());
date.setDate(date.getDate() + days);
return date;
}
Insert cell
function getDates(startDate, stopDate) {
var dateArray = new Array();
var currentDate = startDate;
while (currentDate <= stopDate) {
dateArray.push(new Date (currentDate));
currentDate = currentDate.addDays(1);
}
return dateArray;
}
Insert cell
days2020 = getDates(new Date('2020-01-01'), new Date('2020-12-31'))
Insert cell
formatDay = function(date) {
return ('0'+date.getDate()).slice(-2)
}
Insert cell
formatMonth = function(date) {
return ('0' + (date.getMonth() + 1)).slice(-2)
}
Insert cell
function updateYear(date, year) {
var day = formatDay(date)
var month = formatMonth(date)
return new Date(year + '-' + month + '-' + day)
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more