Bookmark this: tool.io/convert/time/source-code
Convert Time Source Code
Browse the implementation files for Convert Time.tool.ts typescript
import { convertTime as convertPortableTime } from '@tool.io/tools/convert/time';
import { measureFactorOptions } from '../tool';
import { measureFactors } from './factors';
export const convertTime = (
value: number,
from: string,
to: string
) => convertPortableTime(value, from, to) ?? '';
export const Tool: TypeTool = {
name: 'Convert Time',
slug: 'convert/time',
tool: convertTime,
intro:
'Convert durations between SI seconds, common civil units, and explicitly defined year conventions.',
i: [
{
example: '1',
label: 'Value',
placeholder: '1',
type: 'number'
},
{
example: 'h',
label: 'From',
placeholder: 'Select the source time unit',
options: measureFactorOptions(measureFactors, 'h'),
type: 'select',
value: 'h'
},
{
example: 'min',
label: 'To',
placeholder: 'Select the destination time unit',
options: measureFactorOptions(measureFactors, 'min'),
type: 'select',
value: 'min'
}
],
o: [
{
example: '60',
label: 'Time',
placeholder: 'Converted duration',
render: 'textarea',
type: 'number'
}
],
swap: {
inputs: [1, 2],
name: 'Swap time units',
state: false
},
alternative: [
{ title: 'Convert mass', url: '/convert/mass' }
],
cite: [
{
title: 'SI base units — BIPM',
url: 'https://www.bipm.org/en/measurement-units/si-base-units'
}
]
};
export default Tool;
Description
Browse the implementation files for Convert Time.