Skip to content

Instantly share code, notes, and snippets.

@ChristopherHButler
Created October 5, 2020 21:16
Show Gist options
  • Save ChristopherHButler/290c8cd04122e21783b501b1d74039fa to your computer and use it in GitHub Desktop.
Save ChristopherHButler/290c8cd04122e21783b501b1d74039fa to your computer and use it in GitHub Desktop.
Contribution Calc

Contribution Calc

This Gist was generated by Contrived.

Do not modify the metadata file if you want to open in Contrived again. Otherwise, it is safe to delete.

Happy Hacking!

{"user":"5f0c542a4a2ce5e528e01fdf","templateVersion":"1","templateId":"evaljs","resources":[],"dependencies":[],"files":[{"id":1,"parentId":0,"name":"src","path":"/src","type":"folder","isRoot":true,"selected":false,"expanded":true,"children":[{"id":2,"name":"index.js"}]},{"id":2,"parentId":1,"name":"index.js","path":"/src/index.js","type":"file","mimeType":"es6","isRoot":false,"open":true,"selected":true,"content":""}],"experimentId":"5f7b89775556113114e18d8f"}
/* Gist files cannot be empty */
<!-- Gist files cannot be empty -->
const generateLastYearOfDays = () => {
return Array(364).fill(null).map((_, i) => {
let day = new Date();
day.setDate(day.getDate() - i);
return {
date: day,
};
});
};
// generateLastYearOfDays();
const generateLastYearOfMonths = () => {
const shorts = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
return Array(12).fill(null).map((_, i) => {
let month = new Date();
month.setMonth(month.getMonth() - i);
return {
month,
display: shorts[month.getMonth()],
};
});
};
// generateLastYearOfMonths();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment