- If the area you’re applying from or if the event is located outside of PST, please note the time on your permit may not accurately reflect the time your event is scheduled to start. Please contact the LCRB team at LCRB.SEP@gov.bc.ca
+ Please note that the time on the license you receive will be in America / Vancouver time zone. For more information please contact the LCRB team at LCRB.SEP@gov.bc.ca
-
+
diff --git a/cllc-public-app/ClientApp/src/app/components/sep/sep-application/event/event.component.ts b/cllc-public-app/ClientApp/src/app/components/sep/sep-application/event/event.component.ts
index e8f3aaab79..fbaa496eb2 100644
--- a/cllc-public-app/ClientApp/src/app/components/sep/sep-application/event/event.component.ts
+++ b/cllc-public-app/ClientApp/src/app/components/sep/sep-application/event/event.component.ts
@@ -35,7 +35,7 @@ export class EventComponent extends FormBase implements OnInit {
validationMessages: string[];
previewCities: AutoCompleteItem[] = [];
autocompleteCities: AutoCompleteItem[] = [];
- isPacificTimeZone: boolean;
+ isPacificTimeZone: boolean = true;
isOpen: boolean[][] = [];
get minDate() {
return new Date();
@@ -86,7 +86,7 @@ export class EventComponent extends FormBase implements OnInit {
}
ngOnInit(): void {
- this.isPacificTimeZone = true;
+
// create a form for the basic details
this.form = this.fb.group({
sepCity: ["", [Validators.required, Validators.minLength(2)]],
@@ -122,9 +122,7 @@ export class EventComponent extends FormBase implements OnInit {
}
});
}
- checkTimeZone() {
- this.isPacificTimeZone = !this.isPacificTimeZone;
- }
+
setFormValue(app: SepApplication) {
// if there's an app
if (app) {
@@ -272,10 +270,11 @@ export class EventComponent extends FormBase implements OnInit {
serviceStartValue: ["9:00 AM", [Validators.required]],
serviceEndValue: ["9:30 PM", [Validators.required]],
liquorServiceHoursExtensionReason: [""],
- disturbancePreventionMeasuresDetails: [""]
+ disturbancePreventionMeasuresDetails: [""],
+ isPacificTimeZone: [this.isPacificTimeZone]
}, { validators: eventTimesValidator });
- eventDate = Object.assign(new SepSchedule(null), eventDate);
+ eventDate = Object.assign(new SepSchedule(null, this.isPacificTimeZone), eventDate);
const val = eventDate.toEventFormValue();
// Set default to event start date
@@ -283,9 +282,14 @@ export class EventComponent extends FormBase implements OnInit {
val.eventDate = this?.sepApplication?.eventStartDate;
}
datesForm.patchValue(val);
+
+ datesForm.get('isPacificTimeZone').valueChanges.subscribe(value => {
+ this.isPacificTimeZone = value;
+ });
+
return datesForm;
}
-
+
getIsOpen(locationIndex: number, eventIndex: number): boolean {
if(this.isOpen[locationIndex] === undefined) {
return true;
@@ -450,7 +454,7 @@ export class EventComponent extends FormBase implements OnInit {
formData?.eventLocations.forEach(location => {
const dateValues = [];
location?.eventDates.forEach(sched => {
- dateValues.push(new SepSchedule(sched));
+ dateValues.push(new SepSchedule(sched, this.isPacificTimeZone));
});
location.eventDates = dateValues;
});
@@ -506,5 +510,4 @@ export class EventComponent extends FormBase implements OnInit {
this.showValidationMessages = true;
}
}
-
}
diff --git a/cllc-public-app/ClientApp/src/app/components/sep/sep-application/summary/summary.component.ts b/cllc-public-app/ClientApp/src/app/components/sep/sep-application/summary/summary.component.ts
index 66dce2b929..36cc301975 100644
--- a/cllc-public-app/ClientApp/src/app/components/sep/sep-application/summary/summary.component.ts
+++ b/cllc-public-app/ClientApp/src/app/components/sep/sep-application/summary/summary.component.ts
@@ -244,7 +244,7 @@ export class SummaryComponent implements OnInit {
if (loc.eventDates?.length > 0) {
const formatterdDates = [];
loc.eventDates.forEach(ed => {
- ed = Object.assign(new SepSchedule(null), ed);
+ ed = Object.assign(new SepSchedule(null, null), ed);
formatterdDates.push({ ed, ...ed.toEventFormValue() });
});
loc.eventDates = formatterdDates;
diff --git a/cllc-public-app/ClientApp/src/app/models/sep-schedule.model.ts b/cllc-public-app/ClientApp/src/app/models/sep-schedule.model.ts
index 6d16bc3c1c..8b368361b4 100644
--- a/cllc-public-app/ClientApp/src/app/models/sep-schedule.model.ts
+++ b/cllc-public-app/ClientApp/src/app/models/sep-schedule.model.ts
@@ -1,4 +1,5 @@
import { format, addDays } from "date-fns";
+import * as moment from 'moment-timezone';
export class SepSchedule {
id: string; // server side primary key
@@ -10,80 +11,103 @@ export class SepSchedule {
serviceEnd: Date;
liquorServiceHoursExtensionReason: string;
disturbancePreventionMeasuresDetails: string;
+ readonly vancouverTimeZone: string = "America/Vancouver";
+ readonly edmontonTimeZone: string = "America/Edmonton";
- constructor(sched: IEventFormValue) {
+
+ constructor(sched: IEventFormValue, isPacificTimeZone: boolean) {
+ const timeZone = isPacificTimeZone ? this.vancouverTimeZone : this.edmontonTimeZone;
if (sched) {
this.id = sched.id;
- this.eventStart = this.formatDate(sched.eventDate, sched.eventStartValue);
- this.eventEnd = this.formatDate(sched.eventDate, sched.eventEndValue);
- this.serviceStart = this.formatDate(sched.eventDate, sched.serviceStartValue);
- this.serviceEnd = this.formatDate(sched.eventDate, sched.serviceEndValue);
+ this.eventStart = this.formatDate(sched.eventDate, sched.eventStartValue, isPacificTimeZone);
+ this.eventEnd = this.formatDate(sched.eventDate, sched.eventEndValue, isPacificTimeZone);
+ this.serviceStart = this.formatDate(sched.eventDate, sched.serviceStartValue, isPacificTimeZone);
+ this.serviceEnd = this.formatDate(sched.eventDate, sched.serviceEndValue, isPacificTimeZone);
this.liquorServiceHoursExtensionReason = sched.liquorServiceHoursExtensionReason;
this.disturbancePreventionMeasuresDetails = sched.disturbancePreventionMeasuresDetails;
}
}
+ // Convert the SepSchedule object to an IEventFormValue object
toEventFormValue(): IEventFormValue {
const result = { id: this.id } as IEventFormValue;
result.eventDate = this.eventStart;
-
-
if (this.eventStart) {
result.eventStartValue = format(new Date(this.eventStart), "h:mm aa");
}
+
if (this.eventEnd) {
result.eventEndValue = format(new Date(this.eventEnd), "h:mm aa");
}
+
if (this.serviceStart) {
result.serviceStartValue = format(new Date(this.serviceStart), "h:mm aa");
}
+
if (this.serviceEnd) {
result.serviceEndValue = format(new Date(this.serviceEnd), "h:mm aa");
}
+
result.liquorServiceHoursExtensionReason = this.liquorServiceHoursExtensionReason;
result.disturbancePreventionMeasuresDetails = this.disturbancePreventionMeasuresDetails;
return result;
}
+ // Get the number of service hours
getServiceHours(): number {
const serviceHours = parseInt(format(new Date(this.serviceEnd), "H")) - parseInt(format(new Date(this.serviceStart), "H"));
return serviceHours;
}
+ // Check if the time is after 12:00 AM
+ private isNextDay(time: string): boolean {
+ const dayBreakIndex = TIME_SLOTS.indexOf(TIME_SLOTS.find(slot => slot.dayBreak === true));
+ const timeIndex = TIME_SLOTS.indexOf(TIME_SLOTS.find(slot => slot.value === time));
+ return timeIndex >= dayBreakIndex;
+ }
- /**
- *
- * @param eventDate
- * @param time, assumed format "HH:MM [AM,PM]" e.g. '6:30 PM'
- */
- private formatDate(eventDate: Date, time: string): Date {
-
+ // Convert the time to 24-hour format and convert the date to Pacific Time
+ private formatDate(eventDate: Date, time: string, isPacificTimeZone: boolean): Date {
let tempDate = new Date(eventDate);
-
- // let day = parseInt(format(new Date(eventDate), "dd"), 10);
-
- // console.log("formatting date: ", eventDate, time)
+
if (this.isNextDay(time)) {
- // console.log("is next day")
tempDate = addDays(tempDate, 1);
- // day += 1;
}
- // const dateString = `${day} ${format(tempDate, "d MMM yyyy")} ${time}`;
- const dateString = `${format(tempDate, "d MMM yyyy")} ${time}`;
- // console.log("dateString:",dateString);
- const result = new Date(dateString);
- // console.log("result is: ", result);
- return result;
+
+ // Convert time to 24-hour format
+ const time24 = convertTo24Hour(time);
+
+ // Create a date string in the format "yyyy-MM-ddTHH:mm:ss"
+ const dateString = `${format(tempDate, "yyyy-MM-dd")}T${time24}`;
+
+ // Convert the date string to Pacific Time
+ let dateInPacific = moment.tz(dateString, "America/Los_Angeles");
+
+ // Convert to UTC, subtract an hour if isPacificTimeZone is false
+ if (!isPacificTimeZone) {
+ dateInPacific = dateInPacific.clone().tz("UTC").add(-1, 'hours');
+ } else {
+ dateInPacific = dateInPacific.clone().tz("UTC");
+ }
+
+ return dateInPacific.toDate();
}
+}
- private isNextDay(time: string): boolean {
- const dayBreakIndex = TIME_SLOTS.indexOf(TIME_SLOTS.find(slot => slot.dayBreak === true));
- const timeIndex = TIME_SLOTS.indexOf(TIME_SLOTS.find(slot => slot.value === time));
- return timeIndex >= dayBreakIndex;
+// Convert the time to 24-hour format
+function convertTo24Hour(time) {
+ const [main, period] = time.split(' ');
+ let [hours, minutes] = main.split(':');
+
+ if (period === 'PM' && hours !== '12') {
+ hours = (Number(hours) + 12).toString();
+ } else if (period === 'AM' && hours === '12') {
+ hours = '00';
}
+ return `${hours.padStart(2, '0')}:${minutes}`;
}