diff --git a/src/Utils/index.ts b/src/Utils/index.ts new file mode 100644 index 0000000..c3e1d0d --- /dev/null +++ b/src/Utils/index.ts @@ -0,0 +1 @@ +export { Utils, IndiaTZName } from './utils'; \ No newline at end of file diff --git a/src/Utils/utils.ts b/src/Utils/utils.ts new file mode 100644 index 0000000..18ece61 --- /dev/null +++ b/src/Utils/utils.ts @@ -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()); + } +} \ No newline at end of file diff --git a/src/index.css b/src/index.css index b4cc725..4c1b2fc 100644 --- a/src/index.css +++ b/src/index.css @@ -1,5 +1,15 @@ -body { +*,*::before,*::after { + box-sizing: border-box; +} + +html, body { margin: 0; padding: 0; + + width: 100%; + height: 100%; +} + +body { font-family: sans-serif; }