TimeUtils.ts 784 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import moment from 'moment';
  2. function today() {
  3. return __DEV__
  4. ? '2020-06-17 00:00:00,2020-06-17 23:59:59'
  5. : moment().format('YYYY-MM-DD') +
  6. ' 00:00:00,' +
  7. moment().add(1, 'days').format('YYYY-MM-DD') +
  8. ' 00:00:00';
  9. }
  10. function getSearchDate(showDate) {
  11. return (
  12. showDate +
  13. ' 00:00:00,' +
  14. moment(showDate, 'yyyy-MM')
  15. .add(1, 'months')
  16. .add(-1, 'seconds')
  17. .format('yyyy-MM-DD') +
  18. ' 23:59:59'
  19. );
  20. }
  21. class MonthDate {
  22. constructor() {
  23. var list = [];
  24. for (let i = 0; i < 6; i++) {
  25. list.push(
  26. moment()
  27. .add(0 - i, 'months')
  28. .format('yyyy-MM')
  29. );
  30. }
  31. this.showList = list;
  32. }
  33. }
  34. export { today, MonthDate, getSearchDate };