24hto12hformat 中文文档教程
24hto12hformat
从 24 小时制 hh:mm
转换为 12 小时制 hh:mm +merdian
或 hh:mm:ss +merdian
格式。
Usage
安装:
yarn add 24hto12hformat
# or
npm install 24hto12hformat --save
在您的代码中:
import timeFormatter from '24hto12hformat';
timeFormatter('13:30'); // => 1:30 pm
// same as timeFormatter('13:30', false);
// but
timeFormatter('13:30', true); // => 1:30 PM
// works fine
timeFormatter('15:33:29 GMT+020'); // => 3:33 pm
// to add seconds:
timeFormatter('13:30', true, true); // => 1:30:00 PM
timeFormatter('13:30:13', true, true); // => 1:30:13 PM
Contract
/**
*
* @param {string} time
* @param {boolean} uppercase
* @param {boolean} includeSeconds
* @return {string}
*/
如果提供的 time
参数不是 string
,或者它不是以 hh:mm
格式开始,然后模块将以字符串的形式抛出异常。
Other Notes
有趣的事实:这个包的原始名称(24h-to-12h-format
)无法发布到 NPM,因为他们的系统认为它是垃圾邮件名称。 :)
24hto12hformat
Converts from 24-hour hh:mm
to 12-hour hh:mm +merdian
or hh:mm:ss +merdian
format.
Usage
Install:
yarn add 24hto12hformat
# or
npm install 24hto12hformat --save
In your code:
import timeFormatter from '24hto12hformat';
timeFormatter('13:30'); // => 1:30 pm
// same as timeFormatter('13:30', false);
// but
timeFormatter('13:30', true); // => 1:30 PM
// works fine
timeFormatter('15:33:29 GMT+020'); // => 3:33 pm
// to add seconds:
timeFormatter('13:30', true, true); // => 1:30:00 PM
timeFormatter('13:30:13', true, true); // => 1:30:13 PM
Contract
/**
*
* @param {string} time
* @param {boolean} uppercase
* @param {boolean} includeSeconds
* @return {string}
*/
If the the supplied time
argument is not a string
, or it does not start in the hh:mm
format, then the module will throw an exception in the form of a string.
Other Notes
Fun fact: the original name of this package (24h-to-12h-format
) could not be published to NPM due to their system considering it a spam name. :)
更多
你可能也喜欢
- 1st 中文文档教程
- @0x-lerna-fork/timer 中文文档教程
- @0xproject/monorepo-scripts 中文文档教程
- @2bitlab/fetch 中文文档教程
- @aatif-packages/components 中文文档教程
- @abstractpoint/subatomic 中文文档教程
- @abstraqt-dev/jsxknockout 中文文档教程
- @achipiga1/mangle-css-class-webpack-plugin 中文文档教程
- @acodez/profilepreviewsmall 中文文档教程
- @actbase/react-native-kakao-channel 中文文档教程