forked from Neeleshrj/TimeLy
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcountdown.jsx
More file actions
91 lines (67 loc) · 2.81 KB
/
Copy pathcountdown.jsx
File metadata and controls
91 lines (67 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import AsyncStorage from "@react-native-async-storage/async-storage";
import React, { useEffect, useState } from "react";
import ClassList from "../ClassList";
export default function CountDown(){
constructor(props)
{
super(props);
this.state = { datas : "",setCurrentDay:"",lecLists=[],nxt=0 };
}
function setDay(){
var n = new Date().getDay();
var days = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]
this.setState({setCurrentDay:days[n]}) ;
this.setState({datas:ClassList(this.state.setCurrentDay)});
}
function setTimings(){
datas.forEach(async(l)=>{
this.state.lecLists.push(l.from)
})
}
function renderCount(){
if (lecLists.length == 0){
setDay()
setTimings()
renderCount()
}
else{
const nextClassTime = this.state.nxt;
const currentTime = new Date().getTime()
if (nextClassTime-currentTime > 0){
const gap = nextClassTime-currentTime
}
else if (currentTime>nextClassTime && currentTime<=(nextClassTime+2400000)){
const gap = 0;
}
else{
this.state.lecLists.pop()
this.setState({nxt:lecLists[0]})
}
const sec = 1000;
const min = sec*60;
const hr = min*60;
const day = hr*24;
const daysMore = Math.floor(gap/day);
const hoursMore = Math.floor((gap%day)/hr);
const minsMore = Math.floor((gap%day)/min);
const secsMore = Math.floor((gap%day)/sec);
return(
<div className="container">
<div className="container">
You have a class in
</div>
<div className = "container">
{daysMore}:{hoursMore}:{minsMore}:{secsMore}
</div>
</div>
)
}
}
if (lecLists.length == 0){
setDay()
setTimings()
}
else{
setInterval(renderCount(),1000)
}
}