MCPcopy
hub / github.com/formatjs/formatjs / valueToSeconds

Function valueToSeconds

packages/react-intl/components/relative.tsx:47–62  ·  view source on GitHub ↗
(
  value?: number,
  unit?: Intl.RelativeTimeFormatUnit
)

Source from the content-addressed store, hash-verified

45}
46
47function valueToSeconds(
48 value?: number,
49 unit?: Intl.RelativeTimeFormatUnit
50): number {
51 if (!value) {
52 return 0
53 }
54 switch (unit) {
55 case 'second':
56 return value
57 case 'minute':
58 return value * MINUTE
59 default:
60 return value * HOUR
61 }
62}
63
64export interface Props extends FormatRelativeTimeOptions {
65 value?: number

Callers 1

FormattedRelativeTimeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected