Skip to content

Commit

Permalink
Drops created with Date
Browse files Browse the repository at this point in the history
  • Loading branch information
jm42 committed Jun 27, 2024
1 parent 2ca7f8d commit 838ab64
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
16 changes: 13 additions & 3 deletions packages/drops/src/DropsClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
createOrderBy,
createBoolFilter,
createLikeFilter,
toPOAPDate,
} from '@poap-xyz/utils';
import { Drop } from './domain/Drop';
import {
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions packages/drops/src/types/CreateDropsInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions packages/utils/src/format/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './removeSpecialCharacters';
export * from './toPOAPDate';
9 changes: 9 additions & 0 deletions packages/utils/src/format/toPOAPDate.ts
Original file line number Diff line number Diff line change
@@ -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, '-');
}

0 comments on commit 838ab64

Please sign in to comment.