zoukankan      html  css  js  c++  java
  • 日历封装

    getManthDate (year, month) {
            this.year = parseInt(year)
            this.month = parseInt(month)
            if (month === 13) {
              month = 1
              this.month = 1
              year += 1
              this.year += 1
            }
            if (month === 0) {
              month = 12
              this.month = 12
              year -= 1
              this.year -= 1
            }
            var tempArray = []
            var ret = []
            if (!year || !month) {
              var today = new Date()
              year = today.getFullYear()
              month = today.getMonth() + 1
              this.year = year
              this.month = month
            }
            var firstDay = new Date(year, month - 1, 1)
            var firstWeekDay = firstDay.getDay()
            firstWeekDay = firstWeekDay === 0 ? 7 : firstWeekDay
            var lastDayofLastMonth = new Date(year, month - 1, 0)
            var lastDateOfLastMonth = lastDayofLastMonth.getDate()
            var preMonthDayCount = firstWeekDay - 1
            var lastDay = new Date(year, month, 0)
            console.log('lastDay', lastDay)
            var lastDate = lastDay.getDate()
            for (let i = 0; i < 6 * 7; i++) {
              var date = i + 1 - preMonthDayCount
              var isActiveMonth = 1
              var showDate = date
              var thisMonth = month
              if (date <= 0) {
                isActiveMonth = 0
                thisMonth = month - 1
                showDate = lastDateOfLastMonth + date
              } else if (date > lastDate) {
                isActiveMonth = 2
                thisMonth = month + 1
                showDate = showDate - lastDate
              }
              thisMonth = thisMonth === 0 ? 12 : thisMonth
              thisMonth = thisMonth === 13 ? 1 : thisMonth
              tempArray.push({
                isAct: isActiveMonth,
                month: thisMonth,
                date: date,
                showDate: showDate
              })
            }
            for (let j = 0; j < tempArray.length; j += 7) {
              ret.push(tempArray.slice(j, j + 7))
            }
            this.days = ret
            if (!this.dateString) {
              this.selectedDate = new Date().getDate()
            } else {
              this.selectedDate = parseInt(this.dateString.split('-')[2])
            }
            console.log(this.days, 'days')
            console.log('selectedDate', this.selectedDate)
            console.log('year', this.year)
            console.log('month', this.month)
          }
    
  • 相关阅读:
    u-boot.lds分析
    u-boot的makefile中的一些目录的设定,以及涉及的shell,make语法。
    u-boot入门第一步,分析mkconfig
    uboot学习——Makefile里的echo使用!
    Linux下的打包与压缩和tar命令!
    关于undefined reference的问题
    JZ2440 编译Uboot1.1.6 undefined reference to ‘raise’
    POJ 1094 Sorting It All Out
    链式前向星
    Codeforces Round #197 (Div. 2) A~D
  • 原文地址:https://www.cnblogs.com/langqq/p/9132090.html
Copyright © 2011-2022 走看看