RN 日历 签到 上一个月或下一个月的日历

x
import React, {  Component } from 'react'
import {
View,
Text,
Image,
Modal,
Easing,
Animated,
StyleSheet,
ScrollView,
TouchableOpacity,
} from 'react-native'

import { Metrics } from '../themes/Metrics'

import { colors } from '../themes/Styles'

// import { t } from '../datas'

import { save, query, remove } from '../themes/storage'

import Images from '../Data/Images'


import LinearGradient from 'react-native-linear-gradient'

let signArr = []

const nowDate = new Date()

class SignPage extends Component {
constructor( props) {
super( props)
this. state = {
y: nowDate. getFullYear(),
mon: nowDate. getMonth(),
day: nowDate. getDate(),
clickNum: undefined,
visible: false,
showModal: false,
bounceValue: new Animated. Value( 1), //你可以改变这个值看
rotateValue: new Animated. Value( 0), //旋转角度的初始值
loginIn: undefined
}
}
//获得上一个月的第一天

Zhuan() {

let rr = this. state. mon + 1

return this. state. y + '-' + rr + '-' + 1
}
SignDate() {
// console.log('转化成字符串后的时间', this.Zhuan())
var Nowdate = ( this. Zhuan()). split( "-"), //获取某一日期
NowYear = parseInt( Nowdate[ 0]), //某年份
NowMonth = parseInt( Nowdate[ 1]), //某月份
Nowday = parseInt( Nowdate[ 2]), //某天
date = new Date()
console. log( '改变的月份', NowMonth)
//顶部标题样式
let title = NowYear + '年' + NowMonth + '月'
//获取当前月份第一天为周几
date. setFullYear( NowYear); //把当前年份设为某年
date. setMonth( NowMonth - 1); //把当前月份设为某月
date. setDate( Nowday);
let weeks = [ 0, 1, 2, 3, 4, 5, 6];
//getDay获取当前月份为星期几
let date1 = weeks[ date. getDay()];

//获取当前月份天数
let days = undefined
if ( NowMonth + 1 === 4 || NowMonth + 1 === 6 || NowMonth + 1 === 9 || NowMonth + 1 === 11) {
days = 30
} else if ( NowMonth === 2) {
//世纪年必须要被400整除才为闰年,非世纪年被4整除即可 闰年为29天,平年为28天
if ( this. state. y % 100 === 0) {
//世纪年
if ( this. state. y % 400 == 0) {
days = 29
} else {
days = 28
}
} else {
//非世纪年
if ( this. state. y % 4 === 0) {
days = 29
} else {
days = 28
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值