mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
3112433a58
Summary: Dropdown conditions let you specify a predicate formula that's used to filter choices and references in their respective autocomplete dropdown menus. Test Plan: Python and browser tests (WIP). Reviewers: jarek, paulfitz Reviewed By: jarek Subscribers: dsagal, paulfitz Differential Revision: https://phab.getgrist.com/D4235
22 lines
778 B
TypeScript
22 lines
778 B
TypeScript
import moment from 'moment';
|
|
|
|
/**
|
|
* Given a UTC Date ISO 8601 string (the doc updatedAt string), gives a reader-friendly
|
|
* relative time to now - e.g. 'yesterday', '2 days ago'.
|
|
*/
|
|
export function getTimeFromNow(utcDateISO: string): string {
|
|
const time = moment.utc(utcDateISO);
|
|
const now = moment();
|
|
const diff = now.diff(time, 's');
|
|
if (diff < 0 && diff > -60) {
|
|
// If the time appears to be in the future, but less than a minute
|
|
// in the future, chalk it up to a difference in time
|
|
// synchronization and don't claim the resource will be changed in
|
|
// the future. For larger differences, just report them
|
|
// literally, there's a more serious problem or lack of
|
|
// synchronization.
|
|
return now.fromNow();
|
|
}
|
|
return time.fromNow();
|
|
}
|