This commit is contained in:
zmeyer44 2023-10-30 21:07:08 -04:00
parent 749e36f65a
commit 0a13f67915
2 changed files with 13 additions and 5 deletions

View File

@ -124,7 +124,6 @@ export default function CreateCalendarEventModal() {
if (imageUrl) { if (imageUrl) {
tags.push(["image", imageUrl]); tags.push(["image", imageUrl]);
} }
console.log("Adding ", tags);
const preEvent = { const preEvent = {
content: description, content: description,
pubkey: currentUser.pubkey, pubkey: currentUser.pubkey,
@ -153,7 +152,7 @@ export default function CreateCalendarEventModal() {
toast.error("An error occured"); toast.error("An error occured");
} }
} catch (err) { } catch (err) {
console.log("err", err); console.log("error creating event", err);
} finally { } finally {
setIsLoading(false); setIsLoading(false);
} }

View File

@ -124,6 +124,7 @@ export function convertToTimezone(inputDate: Date, targetTimezone: string) {
dayjs.extend(utc); dayjs.extend(utc);
dayjs.extend(timezone); dayjs.extend(timezone);
let hours = inputDate.getHours().toString(); let hours = inputDate.getHours().toString();
if (hours.length === 1) { if (hours.length === 1) {
hours = "0" + hours; hours = "0" + hours;
} }
@ -131,13 +132,21 @@ export function convertToTimezone(inputDate: Date, targetTimezone: string) {
if (minutes.length === 1) { if (minutes.length === 1) {
minutes = "0" + minutes; minutes = "0" + minutes;
} }
let day = inputDate.getDate().toString();
if (day.length === 1) {
day = "0" + day;
}
let month = (inputDate.getMonth() + 1).toString();
if (month.length === 1) {
month = "0" + month;
}
const dateString = `${inputDate.getFullYear()}-${ const dateString = `${inputDate.getFullYear()}-${month}-${day}T${hours}:${minutes}:00.000Z`;
inputDate.getMonth() + 1
}-${inputDate.getDate()}T${hours}:${minutes}:00.000Z`;
// Get plain date w/o timezones // Get plain date w/o timezones
const initialDate = new Date(dateString); const initialDate = new Date(dateString);
const plainString = initialDate.toISOString().split(".")[0] as string; const plainString = initialDate.toISOString().split(".")[0] as string;
const plain = dayjs.tz(plainString, targetTimezone); const plain = dayjs.tz(plainString, targetTimezone);
return plain.toDate(); return plain.toDate();
} }