@@ -8,18 +8,6 @@ import { durationToMilliseconds, isValidDate } from './utils';
8
8
9
9
const defaultUTCFormat = 'l LTS' ;
10
10
11
- /** Formats a date into a standard string with a moment-style "from now" hint
12
- * ex. 12/21/2017 8:19:36 PM (18 days ago)
13
- */
14
- export function dateWithFromNow ( input : Date ) {
15
- if ( ! isValidDate ( input ) ) {
16
- return unknownValueString ;
17
- }
18
-
19
- const date = moment . utc ( input ) ;
20
- return `${ date . format ( defaultUTCFormat ) } UTC (${ date . fromNow ( ) } )` ;
21
- }
22
-
23
11
/** Formats a date into a moment-style "from now" value */
24
12
export function dateFromNow ( input : Date ) {
25
13
if ( ! isValidDate ( input ) ) {
@@ -51,7 +39,7 @@ export function formatDateUTC(input: Date, formatString?: string) {
51
39
/**
52
40
* Gets human-readable date relative to "now"
53
41
*/
54
- export function formateDateRelative ( input : Date , threshold = 24 * 60 * 60 * 1000 ) {
42
+ export function formatDateRelative ( input : Date , threshold = 24 * 60 * 60 * 1000 ) {
55
43
if ( ! isValidDate ( input ) ) {
56
44
return unknownValueString ;
57
45
}
@@ -72,6 +60,18 @@ export function formatDateLocalTimezone(input: Date) {
72
60
return isValidDate ( input ) ? moment ( input ) . tz ( timezone ) . format ( 'l LTS z' ) : unknownValueString ;
73
61
}
74
62
63
+ /** Formats a date into a standard string with a moment-style "from now" hint
64
+ * ex. 12/21/2017 8:19:36 PM (18 days ago)
65
+ */
66
+ export function dateWithFromNow ( input : Date ) {
67
+ if ( ! isValidDate ( input ) ) {
68
+ return unknownValueString ;
69
+ }
70
+
71
+ const date = moment . utc ( input ) ;
72
+ return `${ formatDateLocalTimezone ( input ) } (${ date . fromNow ( ) } )` ;
73
+ }
74
+
75
75
/** Outputs a value in milliseconds in (H M S) format (ex. 2h 3m 30s) */
76
76
export function millisecondsToHMS ( valueMS : number ) : string {
77
77
if ( valueMS < 0 ) {
0 commit comments