mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-10-08 01:39:57 +08:00
[improvement] extract padZero utils
This commit is contained in:
parent
9e5dd3f5d7
commit
d7e5ee40b5
@ -12,7 +12,6 @@ export default {
|
|||||||
'style-guide.zh-CN': () => import('../markdown/style-guide.zh-CN.md'),
|
'style-guide.zh-CN': () => import('../markdown/style-guide.zh-CN.md'),
|
||||||
'theme.en-US': () => import('../markdown/theme.en-US.md'),
|
'theme.en-US': () => import('../markdown/theme.en-US.md'),
|
||||||
'theme.zh-CN': () => import('../markdown/theme.zh-CN.md'),
|
'theme.zh-CN': () => import('../markdown/theme.zh-CN.md'),
|
||||||
'v2-progress-tracking': () => import('../markdown/v2-progress-tracking.md'),
|
|
||||||
'action-sheet.en-US': () => import('../../packages/action-sheet/en-US.md'),
|
'action-sheet.en-US': () => import('../../packages/action-sheet/en-US.md'),
|
||||||
'action-sheet.zh-CN': () => import('../../packages/action-sheet/zh-CN.md'),
|
'action-sheet.zh-CN': () => import('../../packages/action-sheet/zh-CN.md'),
|
||||||
'address-edit.en-US': () => import('../../packages/address-edit/en-US.md'),
|
'address-edit.en-US': () => import('../../packages/address-edit/en-US.md'),
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
import { use } from '../utils';
|
import { use, padZero } from '../utils';
|
||||||
import { RED } from '../utils/color';
|
import { RED } from '../utils/color';
|
||||||
import Checkbox from '../checkbox';
|
import Checkbox from '../checkbox';
|
||||||
|
|
||||||
const [sfc, bem, t] = use('coupon');
|
const [sfc, bem, t] = use('coupon');
|
||||||
|
|
||||||
function padZero(num) {
|
|
||||||
return (num < 10 ? '0' : '') + num;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getDate(timeStamp) {
|
function getDate(timeStamp) {
|
||||||
const date = new Date(timeStamp * 1000);
|
const date = new Date(timeStamp * 1000);
|
||||||
return `${date.getFullYear()}.${padZero(date.getMonth() + 1)}.${padZero(
|
return `${date.getFullYear()}.${padZero(date.getMonth() + 1)}.${padZero(
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
import { use, range } from '../utils';
|
import { use, range, padZero } from '../utils';
|
||||||
import Picker from '../picker';
|
import Picker from '../picker';
|
||||||
import { pickerProps } from '../picker/shared';
|
import { pickerProps } from '../picker/shared';
|
||||||
import {
|
import {
|
||||||
times,
|
times,
|
||||||
padZero,
|
|
||||||
isValidDate,
|
isValidDate,
|
||||||
getTrueValue,
|
getTrueValue,
|
||||||
getMonthEndDay
|
getMonthEndDay
|
||||||
|
@ -2,10 +2,6 @@ export function isValidDate(date) {
|
|||||||
return Object.prototype.toString.call(date) === '[object Date]' && !isNaN(date.getTime());
|
return Object.prototype.toString.call(date) === '[object Date]' && !isNaN(date.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
export function padZero(val) {
|
|
||||||
return `00${val}`.slice(-2);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function times(n, iteratee) {
|
export function times(n, iteratee) {
|
||||||
let index = -1;
|
let index = -1;
|
||||||
const result = Array(n);
|
const result = Array(n);
|
||||||
|
@ -58,3 +58,7 @@ export function suffixPx(value?: string | number): string | undefined {
|
|||||||
value = String(value);
|
value = String(value);
|
||||||
return isNumber(value) ? `${value}px` : value;
|
return isNumber(value) ? `${value}px` : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function padZero(num: number | string): string {
|
||||||
|
return (num < 10 ? '0' : '') + num;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user