···11"use client";
2233import { cva } from "class-variance-authority";
44-import { endOfDay, format, formatDuration, startOfDay } from "date-fns";
44+import { format, formatDuration } from "date-fns";
55import { ChevronRight, Info } from "lucide-react";
66import Link from "next/link";
77import * as React from "react";
···1313 StatusReportUpdate,
1414} from "@openstatus/db/src/schema";
1515import type { Monitor } from "@openstatus/tinybird";
1616-import { Tracker as OSTracker, classNames } from "@openstatus/tracker";
1616+import {
1717+ Tracker as OSTracker,
1818+ classNames,
1919+ endOfDay,
2020+ startOfDay,
2121+} from "@openstatus/tracker";
1722import {
1823 HoverCard,
1924 HoverCardContent,
···150155 <div
151156 className={cn(
152157 rootClassName,
153153- "h-auto w-1 flex-none rounded-full",
158158+ "h-auto w-1 flex-none rounded-full"
154159 )}
155160 />
156161 <div className="grid flex-1 gap-1">
···245250 Down for{" "}
246251 {formatDuration(
247252 { minutes, hours, days },
248248- { format: ["days", "hours", "minutes", "seconds"], zero: false },
253253+ { format: ["days", "hours", "minutes", "seconds"], zero: false }
249254 )}
250255 </p>
251256 );
+8-1
apps/web/src/lib/timezone.ts
···3434 return `Etc/GMT${offset}` as const;
3535}
36363737+export function getServerTimezoneUTCFormat() {
3838+ const now = new Date();
3939+ const now_utc = new Date(now.toUTCString().slice(0, -4)); // remove the GMT end
4040+4141+ return format(now_utc, "LLL dd, y HH:mm:ss (z)", { timeZone: "UTC" });
4242+}
4343+3744export function getServerTimezoneFormat() {
3838- return format(new Date(), "LLL dd, y HH:mm:ss zzz", { timeZone: "UTC" });
4545+ return format(new Date(), "LLL dd, y HH:mm:ss (z)");
3946}
40474148export function formatDate(date: Date) {
+1
packages/tracker/src/index.ts
···11export * from "./tracker";
22export * from "./types";
33export * from "./config";
44+export * from "./utils";
+12-12
packages/tracker/src/utils.ts
···11export function endOfDay(date: Date): Date {
22 // Create a new Date object to avoid mutating the original date
33- const newDate = new Date(date);
33+ // const newDate = new Date(date);
44+ const newDate = new Date(
55+ Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()),
66+ );
4758 // Set hours, minutes, seconds, and milliseconds to end of day
66- newDate.setHours(23, 59, 59, 999);
99+ newDate.setUTCHours(23, 59, 59, 999);
710811 return newDate;
912}
10131114export function startOfDay(date: Date): Date {
1215 // Create a new Date object to avoid mutating the original date
1313- const newDate = new Date(date);
1616+ // const newDate = new Date(date);
1717+ const newDate = new Date(
1818+ Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()),
1919+ );
14201521 // Set hours, minutes, seconds, and milliseconds to start of day
1616- newDate.setHours(0, 0, 0, 0);
2222+ newDate.setUTCHours(0, 0, 0, 0);
17231824 return newDate;
1925}
20262127export function isSameDay(date1: Date, date2: Date) {
2222- const newDate1 = new Date(date1);
2323- const newDate2 = new Date(date2);
2424-2525- newDate1.setDate(newDate1.getDate());
2626- newDate1.setHours(0, 0, 0, 0);
2727-2828- newDate2.setDate(newDate2.getDate());
2929- newDate2.setHours(0, 0, 0, 0);
2828+ const newDate1 = startOfDay(date1);
2929+ const newDate2 = startOfDay(date2);
30303131 return newDate1.toUTCString() === newDate2.toUTCString();
3232}