Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/ITPNYU/booking-app
Browse files Browse the repository at this point in the history
  • Loading branch information
lucia-gomez committed Sep 25, 2024
2 parents f2f9c74 + f6b6d86 commit 03f8b61
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions booking-app/app.development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ automatic_scaling:
env_variables:
NEXT_PUBLIC_BRANCH_NAME: "development"
NODE_OPTIONS: "--max-old-space-size=4096"
TZ: "America/New_York"

build_env_variables:
NODE_OPTIONS: "--max-old-space-size=4096"
Expand Down
1 change: 1 addition & 0 deletions booking-app/app.production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ automatic_scaling:
env_variables:
NEXT_PUBLIC_BRANCH_NAME: "production"
NODE_OPTIONS: "--max-old-space-size=4096"
TZ: "America/New_York"

build_env_variables:
NODE_OPTIONS: "--max-old-space-size=4096"
Expand Down
1 change: 1 addition & 0 deletions booking-app/app.staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ automatic_scaling:
env_variables:
NEXT_PUBLIC_BRANCH_NAME: "staging"
NODE_OPTIONS: "--max-old-space-size=4096"
TZ: "America/New_York"

build_env_variables:
NODE_OPTIONS: "--max-old-space-size=4096"
Expand Down
20 changes: 15 additions & 5 deletions booking-app/components/src/client/utils/serverDate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Timestamp } from "firebase-admin/firestore";
import { format } from "date-fns";
import { toZonedTime } from "date-fns-tz";
import { parseISO } from "date-fns";
import { format } from "date-fns-tz";

type DateInput = Date | Timestamp | { [key: string]: any } | number | string;

Expand All @@ -16,15 +17,24 @@ const parseTimestamp = (value: DateInput): Timestamp => {
};

export const serverFormatDate = (
input: DateInput,
input: string,
timeZone: string = "America/New_York"
): string => {
if (!input) return "";
try {
const timestamp = parseTimestamp(input);
const utcDate = timestamp.toDate();
const zonedDate = toZonedTime(utcDate, timeZone);
const formattedResult = format(zonedDate, "yyyy-MM-dd hh:mm a");
const date = new Date(timestamp.toDate());
const zonedDate = toZonedTime(date, timeZone);

const formattedResult = format(zonedDate, "yyyy-MM-dd hh:mm a", {
timeZone,
});

console.log("Input:", input);
console.log("Parsed Date:", date.toISOString());
console.log("Zoned Date:", zonedDate.toString());
console.log("Formatted Result:", formattedResult);
console.log("Timezone:", timeZone);

return formattedResult;
} catch (error) {
Expand Down

0 comments on commit 03f8b61

Please sign in to comment.