cfahlgren1 HF staff commited on
Commit
02bf005
1 Parent(s): ecba77a

show trailing 12 months not calendar year

Browse files
Files changed (1) hide show
  1. src/pages/index.tsx +4 -2
src/pages/index.tsx CHANGED
@@ -36,10 +36,12 @@ export default function Home() {
36
  );
37
 
38
  const today = new Date();
39
- const startOfYear = new Date(today.getFullYear(), 0, 1);
 
 
40
 
41
  // generate daily data for each provider
42
- for (let d = new Date(startOfYear); d <= today; d.setDate(d.getDate() + 1)) {
43
  const dateString = d.toISOString().split('T')[0];
44
 
45
  Object.entries(PROVIDERS_MAP).forEach(([provider, { authors }]) => {
 
36
  );
37
 
38
  const today = new Date();
39
+ const startDate = new Date(today);
40
+ startDate.setMonth(today.getMonth() - 11);
41
+ startDate.setDate(1); // start from the first day of the month
42
 
43
  // generate daily data for each provider
44
+ for (let d = new Date(startDate); d <= today; d.setDate(d.getDate() + 1)) {
45
  const dateString = d.toISOString().split('T')[0];
46
 
47
  Object.entries(PROVIDERS_MAP).forEach(([provider, { authors }]) => {