mirror of
https://github.com/bendtherules/buildit-weather-app.git
synced 2026-08-18 13:42:14 +00:00
Add utils for time comparison, add css reset to index
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
export { Utils, IndiaTZName } from './utils';
|
||||||
@@ -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
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user