utils.js 560 B

1234567891011121314151617181920212223242526272829
  1. import { isNaN } from '../utils/validate/number';
  2. export function times(n, iteratee) {
  3. var index = -1;
  4. var result = Array(n);
  5. while (++index < n) {
  6. result[index] = iteratee(index);
  7. }
  8. return result;
  9. }
  10. export function getTrueValue(value) {
  11. if (!value) {
  12. return 0;
  13. }
  14. while (isNaN(parseInt(value, 10))) {
  15. if (value.length > 1) {
  16. value = value.slice(1);
  17. } else {
  18. return 0;
  19. }
  20. }
  21. return parseInt(value, 10);
  22. }
  23. export function getMonthEndDay(year, month) {
  24. return 32 - new Date(year, month - 1, 32).getDate();
  25. }