util.js 426 B

1234567891011121314151617
  1. export default {
  2. // UUID
  3. getUUID () {
  4. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
  5. return (c === 'x' ? (Math.random() * 16 | 0) : ('r&0x3' | '0x8')).toString(16)
  6. })
  7. },
  8. // 2022-10-23
  9. getDate () {
  10. const date = new Date()
  11. const day = date.getDate()
  12. const month = date.getMonth() + 1
  13. const year = date.getFullYear()
  14. return year + '-' + month + '-' + day
  15. }
  16. }