Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

convert to utc

Steven Tey3f8fab5e22e9
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/payouts/client.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/payouts/client.tsx
index 108912db3c..932188c492 100644
--- a/apps/web/app/(ee)/admin.dub.co/(dashboard)/payouts/client.tsx
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/payouts/client.tsx
@@ -48,15 +48,9 @@ export default function PayoutsPageClient() {
const { data: { invoices, timeseriesData } = {}, isLoading } = useSWR<{
invoices: InvoiceData[];
timeseriesData: TimeseriesData[];
- }>(
- `/api/admin/payouts${getQueryString({
- timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
- })}`,
- fetcher,
- {
- keepPreviousData: true,
- },
- );
+ }>(`/api/admin/payouts${getQueryString()}`, fetcher, {
+ keepPreviousData: true,
+ });
const tabs: Tab[] = [
{
@@ -113,9 +107,12 @@ export default function PayoutsPageClient() {
columns: [
{
id: "date",
- header: "Payment Date",
+ header: "Payment Date (UTC)",
accessorKey: "date",
- cell: ({ row }) => formatDateTime(row.original.date),
+ cell: ({ row }) =>
+ formatDateTime(row.original.date, {
+ timeZone: "UTC",
+ }),
},
{
id: "program",
diff --git a/apps/web/app/(ee)/api/admin/payouts/route.ts b/apps/web/app/(ee)/api/admin/payouts/route.ts
index cb9c195424..34cc8010a4 100644
--- a/apps/web/app/(ee)/api/admin/payouts/route.ts
+++ b/apps/web/app/(ee)/api/admin/payouts/route.ts
@@ -3,7 +3,6 @@ import { withAdmin } from "@/lib/auth";
import { sqlGranularityMap } from "@/lib/planetscale/granularity";
import { prisma } from "@dub/prisma";
import { ACME_PROGRAM_ID } from "@dub/utils";
-import { endOfDay, startOfDay } from "date-fns";
import { DateTime } from "luxon";
import { NextResponse } from "next/server";
@@ -18,14 +17,28 @@ interface FormattedTimeseriesPoint extends TimeseriesPoint {
}
export const GET = withAdmin(async ({ searchParams }) => {
- const { interval = "mtd", start, end, timezone = "UTC" } = searchParams;
+ const { interval = "mtd", start, end } = searchParams;
- const { startDate, endDate, granularity } = getStartEndDates({
+ let { startDate, endDate, granularity } = getStartEndDates({
interval,
- start: start ? startOfDay(new Date(start)) : undefined,
- end: end ? endOfDay(new Date(end)) : undefined,
+ start,
+ end,
});
+ const timezone = "UTC";
+ // convert to UTC
+ startDate = DateTime.fromJSDate(startDate)
+ .setZone(timezone)
+ .startOf("day")
+ .toUTC()
+ .toJSDate();
+
+ endDate = DateTime.fromJSDate(endDate)
+ .setZone(timezone)
+ .endOf("day")
+ .toUTC()
+ .toJSDate();
+
// Fetch invoices
const invoices = await prisma.invoice.findMany({
where: {