forked from Ivasoft/mattermost-mobile
* Add app review * Use overlay instead of modal * Add fixes for ios * i18n-extract * Add to milliseconds function * Address review feedback * Add try to queryGlobalValue * added app review illustration * add feedback illustration * Add animations and feedback bot message * Restrict reviews to build environment variable * Fix bug with "dont ask anymore" * Add check for only supported servers * Add missing change * Use for await Co-authored-by: Daniel Espino <danielespino@MacBook-Pro-de-Daniel.local> Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
export function isSameDate(a: Date, b: Date = new Date()): boolean {
|
|
return a.getDate() === b.getDate() && isSameMonth(a, b) && isSameYear(a, b);
|
|
}
|
|
|
|
export function isSameMonth(a: Date, b: Date = new Date()): boolean {
|
|
return a.getMonth() === b.getMonth() && isSameYear(a, b);
|
|
}
|
|
|
|
export function isSameYear(a: Date, b: Date = new Date()): boolean {
|
|
return a.getFullYear() === b.getFullYear();
|
|
}
|
|
|
|
export function isToday(date: Date) {
|
|
const now = new Date();
|
|
|
|
return isSameDate(date, now);
|
|
}
|
|
|
|
export function isYesterday(date: Date): boolean {
|
|
const yesterday = new Date();
|
|
yesterday.setDate(yesterday.getDate() - 1);
|
|
|
|
return isSameDate(date, yesterday);
|
|
}
|
|
|
|
export function toMilliseconds({days, hours, minutes, seconds}: {days?: number; hours?: number; minutes?: number; seconds?: number}) {
|
|
const totalHours = ((days || 0) * 24) + (hours || 0);
|
|
const totalMinutes = (totalHours * 60) + (minutes || 0);
|
|
const totalSeconds = (totalMinutes * 60) + (seconds || 0);
|
|
return totalSeconds * 1000;
|
|
}
|