Browse Source

fix week recognition

master
DemiSel 3 years ago
parent
commit
9a0fd09c43
3 changed files with 6 additions and 4 deletions
  1. 3
    1
      components/depenses_list.js
  2. 2
    2
      components/list/day_list.js
  3. 1
    1
      components/list/week_list.js

+ 3
- 1
components/depenses_list.js View File

7
 import WeekList from './list/week_list';
7
 import WeekList from './list/week_list';
8
 
8
 
9
 var getDaysArray = function(s,e) {for(var a=[],d=new Date(s);d<=e.setHours(23,59,59);d.setDate(d.getDate()+1)){ a.push(new Date(d));}return a;};
9
 var getDaysArray = function(s,e) {for(var a=[],d=new Date(s);d<=e.setHours(23,59,59);d.setDate(d.getDate()+1)){ a.push(new Date(d));}return a;};
10
-var getWeek=function(i_date){return Math.ceil(((i_date-new Date(i_date.getFullYear(),0,1)+86400000)/86400000)/7)}
10
+var getWeek=function(i_date){
11
+    var first_day = new Date(i_date.getFullYear(),0,1)
12
+    return Math.ceil(((i_date-first_day+ (first_day.getDay()-1) * 86400000)/86400000)/7)}
11
 
13
 
12
 function DepensesList(props)
14
 function DepensesList(props)
13
 {
15
 {

+ 2
- 2
components/list/day_list.js View File

5
 
5
 
6
 export default function DayList(props)
6
 export default function DayList(props)
7
 {
7
 {
8
-    const [ showDepenses, onToggleDepenses] = React.useState(true);
8
+    const [ showDepenses, onToggleDepenses] = React.useState(false);
9
     let content = []
9
     let content = []
10
 
10
 
11
     let total = 0;
11
     let total = 0;
43
                 <Text style={day_list_styles.day_list_day}>{props.date.toDateString()}</Text>
43
                 <Text style={day_list_styles.day_list_day}>{props.date.toDateString()}</Text>
44
                 <Text style={[day_list_styles.day_list_day, {color: text_color}]}>{"Total : "+total}</Text>
44
                 <Text style={[day_list_styles.day_list_day, {color: text_color}]}>{"Total : "+total}</Text>
45
             </Pressable>
45
             </Pressable>
46
-            {showDepenses ? content : <View/>}
46
+            {showDepenses || isCurrentday ? content : <View/>}
47
         </View>
47
         </View>
48
     )
48
     )
49
 }
49
 }

+ 1
- 1
components/list/week_list.js View File

5
 
5
 
6
 export default function WeekList(props)
6
 export default function WeekList(props)
7
 {
7
 {
8
-    const [ showDays, onToggleDays] = React.useState(true);
8
+    const [ showDays, onToggleDays] = React.useState(false);
9
     
9
     
10
     let days = []
10
     let days = []
11
 
11
 

Loading…
Cancel
Save