1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { myPelotonWorkouts } from "https://esm.town/v/andreterron/myPelotonWorkouts";
import { format } from "npm:date-fns@2.30.0";
import { utcToZonedTime } from "npm:date-fns-tz@2.0.0";
export const workedOutByDay = async (timezone: string = "America/Los_Angeles") => {
const workouts = await myPelotonWorkouts();
const byDay: {
[k: string]: any;
} = {};
for (let w of workouts) {
byDay[
format(
utcToZonedTime(new Date(w.start_time * 1000), timezone),
"yyyy-MM-dd",
)
] = w;
}
return byDay;
};
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
December 19, 2023