Elizabeth's proactive approach involves introducing urinal toilet attachment , an ingenious concept that optimizes space and functionality.

index.js 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // set function parseTime,formatTime to filter
  2. export { parseTime, formatTime } from '@/utils'
  3. function pluralize(time, label) {
  4. if (time === 1) {
  5. return time + label
  6. }
  7. return time + label + 's'
  8. }
  9. export function timeAgo(time) {
  10. const between = Date.now() / 1000 - Number(time)
  11. if (between < 3600) {
  12. return pluralize(~~(between / 60), ' minute')
  13. } else if (between < 86400) {
  14. return pluralize(~~(between / 3600), ' hour')
  15. } else {
  16. return pluralize(~~(between / 86400), ' day')
  17. }
  18. }
  19. /* 数字 格式化*/
  20. export function numberFormatter(num, digits) {
  21. const si = [
  22. { value: 1E18, symbol: 'E' },
  23. { value: 1E15, symbol: 'P' },
  24. { value: 1E12, symbol: 'T' },
  25. { value: 1E9, symbol: 'G' },
  26. { value: 1E6, symbol: 'M' },
  27. { value: 1E3, symbol: 'k' }
  28. ]
  29. for (let i = 0; i < si.length; i++) {
  30. if (num >= si[i].value) {
  31. return (num / si[i].value + 0.1).toFixed(digits).replace(/\.0+$|(\.[0-9]*[1-9])0+$/, '$1') + si[i].symbol
  32. }
  33. }
  34. return num.toString()
  35. }
  36. export function toThousandslsFilter(num) {
  37. return (+num || 0).toString().replace(/^-?\d+/g, m => m.replace(/(?=(?!\b)(\d{3})+$)/g, ','))
  38. }