Dates and times should now be handled properly once the server is set on UTC time and the proper timezone offset environment variable is set.

This commit is contained in:
2021-04-02 06:58:38 +05:30
parent 0da16e9548
commit 97579ea9d3
13 changed files with 104 additions and 78 deletions

View File

@ -8,49 +8,39 @@ import { VoucherType } from './voucher-type';
export class Bill {
id: string | undefined;
date: string;
dateTip: string;
pax: number;
customer?: { id: string; name: string };
user: User;
creationDate: string;
creationDateTip: string;
lastEditDate: string;
billId: string;
lastEditDateTip: string;
kotId: string;
billId: string;
table: Table;
customer?: { id: string; name: string };
guest: GuestBook;
// settlements: any[];
voidReason: string;
reason: string;
voucherType: VoucherType;
serial: number;
kots: Kot[];
// reprints: any[];
get dateTip(): string {
return this.date;
}
get creationDateTip(): string {
return this.date;
}
get lastEditDateTip(): string {
return this.date;
}
public constructor(init?: Partial<Bill>) {
this.id = undefined;
this.date = '';
this.dateTip = '';
this.pax = 0;
this.user = new User();
this.creationDate = '';
this.creationDateTip = '';
this.lastEditDate = '';
this.lastEditDateTip = '';
this.billId = '';
this.kotId = '';
this.table = new Table();
this.guest = new GuestBook();
// this.settlements = [];
this.voidReason = '';
this.reason = '';
this.voucherType = VoucherType.Kot;
this.serial = 0;
this.kots = [];
// this.reprints = [];
Object.assign(this, init);

View File

@ -27,12 +27,12 @@
</ng-container>
<ng-container matColumnDef="time-details">
<mat-header-cell *matHeaderCellDef class="deep-purple-100 bold right-align"
><span [matTooltip]="bs.bill.dateTip">{{ bs.bill.date }}</span
>&nbsp;/&nbsp;<span [matTooltip]="bs.bill.creationDateTip">{{
bs.bill.creationDate
><span [matTooltip]="bs.bill.dateTip | localTime">{{ bs.bill.date | localTime }}</span
>&nbsp;/&nbsp;<span [matTooltip]="bs.bill.creationDateTip | localTime">{{
bs.bill.creationDate | localTime
}}</span
>&nbsp;/&nbsp;<span [matTooltip]="bs.bill.lastEditDateTip">{{
bs.bill.lastEditDate
>&nbsp;/&nbsp;<span [matTooltip]="bs.bill.lastEditDateTip | localTime">{{
bs.bill.lastEditDate | localTime
}}</span></mat-header-cell
>
</ng-container>

View File

@ -9,6 +9,11 @@ export class LocalTimePipe implements PipeTransform {
if (value === undefined) {
return '';
}
if (value.length === 5) {
return moment(value, 'HH:mm')
.subtract(new Date().getTimezoneOffset(), 'minutes')
.format('HH:mm');
}
return moment(value, 'DD-MMM-YYYY HH:mm')
.subtract(new Date().getTimezoneOffset(), 'minutes')
.format('DD-MMM-YYYY HH:mm');