@@ -19,7 +19,7 @@ export default (o, c, d) => {
19
19
yy : '%d years'
20
20
}
21
21
d . en . relativeTime = relObj
22
- const fromTo = ( input , withoutSuffix , instance , isFrom ) => {
22
+ proto . fromToBase = ( input , withoutSuffix , instance , isFrom , postFormat ) => {
23
23
const loc = instance . $locale ( ) . relativeTime || relObj
24
24
const T = o . thresholds || [
25
25
{ l : 's' , r : 44 , d : C . S } ,
@@ -46,11 +46,14 @@ export default (o, c, d) => {
46
46
? d ( input ) . diff ( instance , t . d , true )
47
47
: instance . diff ( input , t . d , true )
48
48
}
49
- const abs = ( o . rounding || Math . round ) ( Math . abs ( result ) )
49
+ let abs = ( o . rounding || Math . round ) ( Math . abs ( result ) )
50
50
isFuture = result > 0
51
51
if ( abs <= t . r || ! t . r ) {
52
52
if ( abs <= 1 && i > 0 ) t = T [ i - 1 ] // 1 minutes -> a minute, 0 seconds -> 0 second
53
53
const format = loc [ t . l ]
54
+ if ( postFormat ) {
55
+ abs = postFormat ( `${ abs } ` )
56
+ }
54
57
if ( typeof format === 'string' ) {
55
58
out = format . replace ( '%d' , abs )
56
59
} else {
@@ -66,6 +69,11 @@ export default (o, c, d) => {
66
69
}
67
70
return pastOrFuture . replace ( '%s' , out )
68
71
}
72
+
73
+ function fromTo ( input , withoutSuffix , instance , isFrom ) {
74
+ return proto . fromToBase ( input , withoutSuffix , instance , isFrom )
75
+ }
76
+
69
77
proto . to = function ( input , withoutSuffix ) {
70
78
return fromTo ( input , withoutSuffix , this , true )
71
79
}
0 commit comments