mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-25 23:16:56 +00:00
Eslint/fix lint date time utility (#471)
* fixed lint issue of DateTimeUtility * remove commented code * Do change request.
This commit is contained in:
parent
d85b6285ac
commit
4807169b0c
@ -176,8 +176,6 @@ src/Explorer/Tables/Entities.ts
|
|||||||
src/Explorer/Tables/QueryBuilder/ClauseGroup.ts
|
src/Explorer/Tables/QueryBuilder/ClauseGroup.ts
|
||||||
src/Explorer/Tables/QueryBuilder/ClauseGroupViewModel.ts
|
src/Explorer/Tables/QueryBuilder/ClauseGroupViewModel.ts
|
||||||
src/Explorer/Tables/QueryBuilder/CustomTimestampHelper.ts
|
src/Explorer/Tables/QueryBuilder/CustomTimestampHelper.ts
|
||||||
src/Explorer/Tables/QueryBuilder/DateTimeUtilities.test.ts
|
|
||||||
src/Explorer/Tables/QueryBuilder/DateTimeUtilities.ts
|
|
||||||
src/Explorer/Tables/QueryBuilder/QueryBuilderViewModel.ts
|
src/Explorer/Tables/QueryBuilder/QueryBuilderViewModel.ts
|
||||||
src/Explorer/Tables/QueryBuilder/QueryClauseViewModel.ts
|
src/Explorer/Tables/QueryBuilder/QueryClauseViewModel.ts
|
||||||
src/Explorer/Tables/QueryBuilder/QueryViewModel.ts
|
src/Explorer/Tables/QueryBuilder/QueryViewModel.ts
|
||||||
|
@ -2,26 +2,26 @@ const epochTicks = 621355968000000000;
|
|||||||
const ticksPerMillisecond = 10000;
|
const ticksPerMillisecond = 10000;
|
||||||
|
|
||||||
export function getLocalDateTime(dateTime: string): string {
|
export function getLocalDateTime(dateTime: string): string {
|
||||||
var dateTimeObject: Date = new Date(dateTime);
|
const dateTimeObject: Date = new Date(dateTime);
|
||||||
var year: number = dateTimeObject.getFullYear();
|
const year: number = dateTimeObject.getFullYear();
|
||||||
var month: string = ensureDoubleDigits(dateTimeObject.getMonth() + 1); // Month ranges from 0 to 11
|
const month: string = ensureDoubleDigits(dateTimeObject.getMonth() + 1); // Month ranges from 0 to 11
|
||||||
var day: string = ensureDoubleDigits(dateTimeObject.getDate());
|
const day: string = ensureDoubleDigits(dateTimeObject.getDate());
|
||||||
var hours: string = ensureDoubleDigits(dateTimeObject.getHours());
|
const hours: string = ensureDoubleDigits(dateTimeObject.getHours());
|
||||||
var minutes: string = ensureDoubleDigits(dateTimeObject.getMinutes());
|
const minutes: string = ensureDoubleDigits(dateTimeObject.getMinutes());
|
||||||
var seconds: string = ensureDoubleDigits(dateTimeObject.getSeconds());
|
const seconds: string = ensureDoubleDigits(dateTimeObject.getSeconds());
|
||||||
var milliseconds: string = ensureTripleDigits(dateTimeObject.getMilliseconds());
|
const milliseconds: string = ensureTripleDigits(dateTimeObject.getMilliseconds());
|
||||||
|
|
||||||
var localDateTime: string = `${year}-${month}-${day}T${hours}:${minutes}:${seconds}.${milliseconds}`;
|
const localDateTime = `${year}-${month}-${day}T${hours}:${minutes}:${seconds}.${milliseconds}`;
|
||||||
return localDateTime;
|
return localDateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getUTCDateTime(dateTime: string): string {
|
export function getUTCDateTime(dateTime: string): string {
|
||||||
var dateTimeObject: Date = new Date(dateTime);
|
const dateTimeObject = new Date(dateTime);
|
||||||
return dateTimeObject.toISOString();
|
return dateTimeObject.toISOString();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ensureDoubleDigits(num: number): string {
|
export function ensureDoubleDigits(num: number): string {
|
||||||
var doubleDigitsString: string = num.toString();
|
let doubleDigitsString: string = num.toString();
|
||||||
if (num < 10) {
|
if (num < 10) {
|
||||||
doubleDigitsString = `0${doubleDigitsString}`;
|
doubleDigitsString = `0${doubleDigitsString}`;
|
||||||
} else if (num > 99) {
|
} else if (num > 99) {
|
||||||
@ -31,7 +31,7 @@ export function ensureDoubleDigits(num: number): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function ensureTripleDigits(num: number): string {
|
export function ensureTripleDigits(num: number): string {
|
||||||
var tripleDigitsString: string = num.toString();
|
let tripleDigitsString: string = num.toString();
|
||||||
if (num < 10) {
|
if (num < 10) {
|
||||||
tripleDigitsString = `00${tripleDigitsString}`;
|
tripleDigitsString = `00${tripleDigitsString}`;
|
||||||
} else if (num < 100) {
|
} else if (num < 100) {
|
||||||
@ -51,17 +51,17 @@ export function convertJSDateToUnix(dateTime: string): number {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function convertTicksToJSDate(ticks: string): Date {
|
export function convertTicksToJSDate(ticks: string): Date {
|
||||||
var ticksJSBased = Number(ticks) - epochTicks;
|
const ticksJSBased = Number(ticks) - epochTicks;
|
||||||
var timeInMillisecond = ticksJSBased / ticksPerMillisecond;
|
const timeInMillisecond = ticksJSBased / ticksPerMillisecond;
|
||||||
return new Date(timeInMillisecond);
|
return new Date(timeInMillisecond);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function convertJSDateToTicksWithPadding(dateTime: string): string {
|
export function convertJSDateToTicksWithPadding(dateTime: string): string {
|
||||||
var ticks = epochTicks + new Date(dateTime).getTime() * ticksPerMillisecond;
|
const ticks = epochTicks + new Date(dateTime).getTime() * ticksPerMillisecond;
|
||||||
return padDateTicksWithZeros(ticks.toString());
|
return padDateTicksWithZeros(ticks.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
function padDateTicksWithZeros(value: string): string {
|
function padDateTicksWithZeros(value: string): string {
|
||||||
var s = "0000000000000000000" + value;
|
const s = "0000000000000000000" + value;
|
||||||
return s.substr(s.length - 20);
|
return s.substr(s.length - 20);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user