index.wxs 768 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* eslint-disable */
  2. var utils = require('./utils.wxs');
  3. function getMonths(minDate, maxDate) {
  4. var months = [];
  5. var cursor = getDate(minDate);
  6. cursor.setDate(1);
  7. cursor.setMinutes(cursor.getMinutes() - cursor.getTimezoneOffset());
  8. do {
  9. months.push(cursor.getTime());
  10. cursor.setMonth(cursor.getMonth() + 1);
  11. } while (utils.compareMonth(cursor, getDate(maxDate)) !== 1);
  12. return months;
  13. }
  14. function getButtonDisabled(type, currentDate) {
  15. if (currentDate == null) {
  16. return true;
  17. }
  18. if (type === 'range') {
  19. return !currentDate[0] || !currentDate[1];
  20. }
  21. if (type === 'multiple') {
  22. return !currentDate.length;
  23. }
  24. return !currentDate;
  25. }
  26. module.exports = {
  27. getMonths: getMonths,
  28. getButtonDisabled: getButtonDisabled
  29. };