mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 21:10:23 +00:00
[hh-mm-ss]: add types for hh-mm-ss module (#41451)
This commit is contained in:
committed by
Armando Aguirre
parent
6e560d4643
commit
1c451788fc
@@ -0,0 +1,13 @@
|
||||
import { fromMs, fromS, toMs, toS } from 'hh-mm-ss';
|
||||
|
||||
const ms = fromMs(60000);
|
||||
const msWithFormat = fromMs(60000, 'mm:ss');
|
||||
|
||||
const s = fromS(3000);
|
||||
const sWithFormat = fromS(3000, 'hh:mm:ss');
|
||||
|
||||
const ms2 = toMs('12:23:34');
|
||||
const msWithFormat2 = toMs('12:23:34', 'mm:ss');
|
||||
|
||||
const s2 = toS('12:23:34');
|
||||
const sWithFormat2 = toS('12:23:34', 'mm:ss');
|
||||
Vendored
+42
@@ -0,0 +1,42 @@
|
||||
// Type definitions for hh-mm-ss 1.2
|
||||
// Project: https://github.com/Goldob/hh-mm-ss#readme
|
||||
// Definitions by: Thomas Cazade <https://github.com/TotomInc>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* Convert given `hh:mm:ss` formatted string to miliseconds
|
||||
*
|
||||
* @param time String representation
|
||||
* @param format Default input format. If present, it will be used to resolve
|
||||
* ambiguities during interpretation. If not specified, `mm:ss` is implied.
|
||||
* [See section below for supported format list](https://github.com/Goldob/hh-mm-ss#supported-time-formats)
|
||||
*/
|
||||
export function toMs(time: string, format?: string): string;
|
||||
|
||||
/**
|
||||
* Convert given `hh:mm:ss` formatted string to seconds
|
||||
*
|
||||
* @param time String representation
|
||||
* @param format Default input format. If present, it will be used to resolve
|
||||
* amiguities during interpretation. If not specified, `mm:ss` is implied.
|
||||
* [See section below for supported format list](https://github.com/Goldob/hh-mm-ss#supported-time-formats)
|
||||
*/
|
||||
export function toS(time: string, format?: string): string;
|
||||
|
||||
/**
|
||||
* Generate formatted string from time in miliseconds
|
||||
*
|
||||
* @param ms Time in miliseconds
|
||||
* @param format Default output format. If not specified, `mm:ss` is implied.
|
||||
* [See section below for supported format list](https://github.com/Goldob/hh-mm-ss#supported-time-formats)
|
||||
*/
|
||||
export function fromMs(ms: number, format?: string): string;
|
||||
|
||||
/**
|
||||
* Generate formatted string from time in seconds
|
||||
*
|
||||
* @param s Time in seconds
|
||||
* @param format Default output format. If not specified, `mm:ss` is implied.
|
||||
* [See section below for supported format list](https://github.com/Goldob/hh-mm-ss#supported-time-formats)
|
||||
*/
|
||||
export function fromS(s: number, format?: string): string;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"hh-mm-ss-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user