material-duration-picker
Version:
React Material component for durations inspired by Material-UI Pickers
39 lines (38 loc) • 1.31 kB
TypeScript
import { DurationType, DurationView } from "./types";
/**
* Converts a number of seconds into a whole number of units of type view
*
* Ex:
* 75 seconds to minutes = 1.25 minutes. Rounded down = 1 minutes
*
* This works with negative numbers
* -75 seconds to minutes = -1.25 minutes. Rounded up = -1 minutes
*
* @param secs The number of seconds
* @param view The view
* @param round if should round
*/
export declare const getValue: (secs: number | undefined, view: DurationView, round?: boolean) => number | undefined;
export declare const getRemainder: (secs: number | undefined, view: DurationView) => number | undefined;
/**
* Converts a time in seconds to a duration
* @param time time in seconds
* @param views Views included in the duration
* @param zeroes If false, views that have a value of zero will be set to undefined
*/
export declare const timeToDuration: (time: number | undefined, views?: DurationView[], zeroes?: boolean) => DurationType;
/**
* Convert a duration to a time value of a view
* If no view is specified, will convert to seconds
*
* Ex:
* duration: {
* hours: 1,
* minutes: 2
* seconds: 30
* }
* view: minutes
*
* res: 62.5
*/
export declare const durationToTime: (duration: DurationType, view?: DurationView | undefined) => number | undefined;