Skip to content

Commit

Permalink
Update src/formatDistance/index.ts
Browse files Browse the repository at this point in the history
Co-authored-by: Sasha Koss <koss@nocorp.me>
  • Loading branch information
a-korzun and kossnocorp committed Mar 29, 2021
1 parent fb0f912 commit d6bdb93
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/formatDistance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import toDate from '../toDate/index'
import cloneObject from '../_lib/cloneObject/index'
import getTimezoneOffsetInMilliseconds from '../_lib/getTimezoneOffsetInMilliseconds/index'
import requiredArgs from '../_lib/requiredArgs/index'
import { LocaleOptions } from '../types';

const MINUTES_IN_DAY = 1440
const MINUTES_IN_ALMOST_TWO_DAYS = 2520
Expand Down Expand Up @@ -121,16 +122,10 @@ const MINUTES_IN_TWO_MONTHS = 86400
* //=> 'pli ol 1 jaro'
*/

export interface Options {
includeSeconds?: boolean
addSuffix?: boolean
locale?: Locale
}

export default function formatDistance(dirtyDate: Date | number, dirtyBaseDate: Date | number, dirtyOptions?: Options) {
export default function formatDistance(dirtyDate: Date | number, dirtyBaseDate: Date | number, options : LocaleOptions & { includeSeconds?: boolean, addSuffix?: boolean } = {}) {
requiredArgs(2, arguments)

const options = dirtyOptions || {}
const locale = options.locale || defaultLocale

if (!locale.formatDistance) {
Expand Down

0 comments on commit d6bdb93

Please sign in to comment.