Skip to content

Latest commit

 

History

History
394 lines (226 loc) · 8.11 KB

File metadata and controls

394 lines (226 loc) · 8.11 KB

Back to README.md

@openmrs/esm-utils

Table of contents

Interfaces

Type aliases

Functions

Type aliases

DateInput

Ƭ DateInput: string | number | Date

Defined in

omrs-dates.ts:8

Functions

age

age(dateString): string

Gets a human readable age represention of the provided date string.

Parameters

Name Type Description
dateString string The stringified date.

Returns

string

A human-readable string version of the age.

Defined in

age-helpers.tsx:37


daysIntoYear

daysIntoYear(date): number

Gets the number of days in the year of the given date.

Parameters

Name Type Description
date Date The date to compute the days within the year.

Returns

number

The number of days.

Defined in

age-helpers.tsx:6


isOmrsDateStrict

isOmrsDateStrict(omrsPayloadString): boolean

This function is STRICT on checking whether a date string is the openmrs format. The format should be YYYY-MM-DDTHH:mm:ss.SSSZZ

Parameters

Name Type
omrsPayloadString string

Returns

boolean

Defined in

omrs-dates.ts:16


isOmrsDateToday

isOmrsDateToday(date): boolean

Parameters

Name Type Description
date DateInput Checks if the provided date is today.

Returns

boolean

Defined in

omrs-dates.ts:53


isSameDay

isSameDay(firstDate, secondDate): boolean

Checks if two dates are representing the same day.

Parameters

Name Type Description
firstDate Date The first date.
secondDate Date The second date.

Returns

boolean

True if both are located on the same day.

Defined in

age-helpers.tsx:23


isVersionSatisfied

isVersionSatisfied(requiredVersion, installedVersion): boolean

Parameters

Name Type
requiredVersion string
installedVersion string

Returns

boolean

Defined in

version.ts:21


retry

retry<T>(fn, options?): Promise<T>

Executes the specified function and retries executing on failure with a custom backoff strategy defined by the options.

If not configured otherwise, this function uses the following default options:

  • Retries 5 times beyond the initial attempt.
  • Uses an exponential backoff starting with an initial delay of 1000ms.

throws Rethrows the final error of running fn when the function stops retrying.

Type parameters

Name
T

Parameters

Name Type Description
fn () => Promise<T> The function to be executed and retried on failure.
options RetryOptions Additional options which configure the retry behavior.

Returns

Promise<T>

The result of successfully executing fn.

Defined in

retry.ts:38


toDateObjectStrict

toDateObjectStrict(omrsDateString): Date | null

Converts the object to a date object if it is a valid ISO date time string.

Parameters

Name Type
omrsDateString string

Returns

Date | null

Defined in

omrs-dates.ts:60


toOmrsDateFormat

toOmrsDateFormat(date, format?): string

Formats the input as a date string. By default the format "YYYY-MMM-DD" is used.

Parameters

Name Type Default value
date DateInput undefined
format string "YYYY-MMM-DD"

Returns

string

Defined in

omrs-dates.ts:112


toOmrsDayDateFormat

toOmrsDayDateFormat(date): string

Formats the input as a date string using the format "DD - MMM - YYYY".

Parameters

Name Type
date DateInput

Returns

string

Defined in

omrs-dates.ts:98


toOmrsIsoString

toOmrsIsoString(date, toUTC?): string

Formats the input as a date time string using the format "YYYY-MM-DDTHH:mm:ss.SSSZZ".

Parameters

Name Type Default value
date DateInput undefined
toUTC boolean false

Returns

string

Defined in

omrs-dates.ts:71


toOmrsTimeString

toOmrsTimeString(date): string

Formats the input as a time string using the format "HH:mm A".

Parameters

Name Type
date DateInput

Returns

string

Defined in

omrs-dates.ts:91


toOmrsTimeString24

toOmrsTimeString24(date): string

Formats the input as a time string using the format "HH:mm".

Parameters

Name Type
date DateInput

Returns

string

Defined in

omrs-dates.ts:84


toOmrsYearlessDateFormat

toOmrsYearlessDateFormat(date): string

Formats the input as a date string using the format "DD-MMM".

Parameters

Name Type
date DateInput

Returns

string

Defined in

omrs-dates.ts:105


translateFrom

translateFrom(moduleName, key, fallback?): string

Parameters

Name Type
moduleName string
key string
fallback? string

Returns

string

Defined in

translate.ts:3