Add timezone handling

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-10-10 16:25:50 +02:00
parent eba3c70c9b
commit d58ca5743d
49 changed files with 1218 additions and 429 deletions

View File

@@ -13,6 +13,7 @@ export interface IAddress {
geom?: string;
url?: string;
originId?: string;
timezone?: string;
}
export interface IPoiInfo {
@@ -44,20 +45,23 @@ export class Address implements IAddress {
geom?: string = "";
timezone?: string = "";
constructor(hash?: IAddress) {
if (!hash) return;
this.id = hash.id;
this.description = hash.description;
this.street = hash.street;
this.locality = hash.locality;
this.postalCode = hash.postalCode;
this.region = hash.region;
this.country = hash.country;
this.description = hash.description?.trim();
this.street = hash.street?.trim();
this.locality = hash.locality?.trim();
this.postalCode = hash.postalCode?.trim();
this.region = hash.region?.trim();
this.country = hash.country?.trim();
this.type = hash.type;
this.geom = hash.geom;
this.url = hash.url;
this.originId = hash.originId;
this.timezone = hash.timezone;
}
get poiInfos(): IPoiInfo {

View File

@@ -26,6 +26,7 @@ export interface IEventOptions {
showParticipationPrice: boolean;
showStartTime: boolean;
showEndTime: boolean;
timezone: string | null;
}
export class EventOptions implements IEventOptions {
@@ -54,4 +55,6 @@ export class EventOptions implements IEventOptions {
showStartTime = true;
showEndTime = true;
timezone = null;
}

View File

@@ -35,7 +35,7 @@ interface IEventEditJSON {
id?: string;
title: string;
description: string;
beginsOn: string;
beginsOn: string | null;
endsOn: string | null;
status: EventStatus;
visibility: EventVisibility;
@@ -92,6 +92,9 @@ export interface IEvent {
toEditJSON(): IEventEditJSON;
}
export interface IEditableEvent extends Omit<IEvent, "beginsOn"> {
beginsOn: Date | null;
}
export class EventModel implements IEvent {
id?: string;
@@ -158,7 +161,7 @@ export class EventModel implements IEvent {
metadata: IEventMetadata[] = [];
constructor(hash?: IEvent) {
constructor(hash?: IEvent | IEditableEvent) {
if (!hash) return;
this.id = hash.id;
@@ -170,8 +173,14 @@ export class EventModel implements IEvent {
this.slug = hash.slug;
this.description = hash.description || "";
this.beginsOn = new Date(hash.beginsOn);
if (hash.endsOn) this.endsOn = new Date(hash.endsOn);
if (hash.beginsOn) {
this.beginsOn = new Date(hash.beginsOn);
}
if (hash.endsOn) {
this.endsOn = new Date(hash.endsOn);
} else {
this.endsOn = null;
}
this.publishAt = new Date(hash.publishAt);
@@ -217,12 +226,12 @@ export function removeTypeName(entity: any): any {
return entity;
}
export function toEditJSON(event: IEvent): IEventEditJSON {
export function toEditJSON(event: IEditableEvent): IEventEditJSON {
return {
id: event.id,
title: event.title,
description: event.description,
beginsOn: event.beginsOn.toISOString(),
beginsOn: event.beginsOn ? event.beginsOn.toISOString() : null,
endsOn: event.endsOn ? event.endsOn.toISOString() : null,
status: event.status,
visibility: event.visibility,