diff --git a/packages/drops/src/DropsClient.ts b/packages/drops/src/DropsClient.ts index 67337bff..a2c102a8 100644 --- a/packages/drops/src/DropsClient.ts +++ b/packages/drops/src/DropsClient.ts @@ -10,6 +10,7 @@ import { createOrderBy, createBoolFilter, createLikeFilter, + toPOAPDate, } from '@poap-xyz/utils'; import { Drop } from './domain/Drop'; import { @@ -148,9 +149,18 @@ export class DropsClient { description: input.description, city: input.city, country: input.country, - start_date: input.startDate, - end_date: input.endDate, - expiry_date: input.expiryDate, + start_date: + input.startDate instanceof Date + ? toPOAPDate(input.startDate) + : input.startDate, + end_date: + input.endDate instanceof Date + ? toPOAPDate(input.endDate) + : input.endDate, + expiry_date: + input.expiryDate instanceof Date + ? toPOAPDate(input.expiryDate) + : input.expiryDate, event_url: input.eventUrl, virtual_event: input.virtualEvent, image: input.image, diff --git a/packages/drops/src/types/CreateDropsInput.ts b/packages/drops/src/types/CreateDropsInput.ts index 8ca18aa0..0ea880fb 100644 --- a/packages/drops/src/types/CreateDropsInput.ts +++ b/packages/drops/src/types/CreateDropsInput.ts @@ -3,9 +3,9 @@ export interface CreateDropsInput { description: string; city: string; country: string; - startDate: string; - endDate: string; - expiryDate: string; + startDate: string | Date; + endDate: string | Date; + expiryDate: string | Date; eventUrl: string; virtualEvent: boolean; image: Blob; diff --git a/packages/utils/src/format/index.ts b/packages/utils/src/format/index.ts index 9aa215bd..dbf78c49 100644 --- a/packages/utils/src/format/index.ts +++ b/packages/utils/src/format/index.ts @@ -1 +1,2 @@ export * from './removeSpecialCharacters'; +export * from './toPOAPDate'; diff --git a/packages/utils/src/format/toPOAPDate.ts b/packages/utils/src/format/toPOAPDate.ts new file mode 100644 index 00000000..4c85b3f3 --- /dev/null +++ b/packages/utils/src/format/toPOAPDate.ts @@ -0,0 +1,9 @@ +export function toPOAPDate(date: Date): string { + return date + .toLocaleDateString('en-US', { + month: '2-digit', + day: '2-digit', + year: 'numeric', + }) + .replace(/\//g, '-'); +}