Add utils for time comparison, add css reset to index

This commit is contained in:
2018-04-01 13:16:21 +05:30
parent 5fcb505848
commit eec5558d21
3 changed files with 35 additions and 1 deletions
+1
View File
@@ -0,0 +1 @@
export { Utils, IndiaTZName } from './utils';
+23
View File
@@ -0,0 +1,23 @@
import * as moment from 'moment-timezone';
export const IndiaTZName = 'Asia/Kolkata';
export class Utils {
static createTodayDateInIndiaTZ(): moment.Moment {
return moment.tz(moment.tz.guess()).tz(IndiaTZName);
}
static createDateFromEpochInIndiaTZ(dateEpoch: number): moment.Moment {
return moment.unix(dateEpoch).tz(IndiaTZName);
}
static checkSameDayInSameTZ(moment1: moment.Moment, moment2: moment.Moment, raiseErrorTZMismatch: boolean = true) {
// tslint:disable-next-line:triple-equals
if (raiseErrorTZMismatch && (moment1.tz() != moment2.tz())) {
throw new Error('Timezones don\'t match');
}
// tslint:disable-next-line:triple-equals
return (moment1.clone().startOf('day').format() == moment2.clone().startOf('day').format());
}
}
+11 -1
View File
@@ -1,5 +1,15 @@
body { *,*::before,*::after {
box-sizing: border-box;
}
html, body {
margin: 0; margin: 0;
padding: 0; padding: 0;
width: 100%;
height: 100%;
}
body {
font-family: sans-serif; font-family: sans-serif;
} }