99
1010const React = require ( 'react' ) ;
1111const PropTypes = require ( 'prop-types' ) ;
12- const moment = require ( 'moment-jalaali' ) ;
13- const {
14- Text,
15- View,
16- } = require ( 'react-native' ) ;
12+ const jMoment = require ( 'moment-jalaali' ) ;
13+ const { Text, View } = require ( 'react-native' ) ;
1714
18- const styles = require ( './style' ) ;
19- const {
20- MAX_ROWS ,
21- MAX_COLUMNS ,
22- } = require ( './util' ) ;
2315const Day = require ( './Day' ) ;
16+ const styles = require ( './style' ) ;
17+ const { MAX_ROWS , MAX_COLUMNS } = require ( './util' ) ;
2418
2519class Days extends React . Component {
2620 static propTypes = {
@@ -60,7 +54,7 @@ class Days extends React.Component {
6054
6155 updateSelectedStates ( day ) {
6256 let selectedStates = [ ] ,
63- daysInMonth = moment . jDaysInMonth ( this . props . year , this . props . month ) ;
57+ daysInMonth = jMoment . jDaysInMonth ( this . props . year , this . props . month ) ;
6458
6559 for ( let i = 1 ; i <= daysInMonth ; i ++ ) {
6660 if ( i === day ) {
@@ -90,21 +84,21 @@ class Days extends React.Component {
9084 month = this . props . month ,
9185 year = this . props . year ,
9286 currentDay = 0 ,
93- thisMonthFirstDay = moment ( year + '/' + ( month + 1 ) + '/1' , 'jYYYY/jM/jD' ) ,
94- dayOfWeek = ( thisMonthFirstDay . weekday ( ) + 1 ) % 7 ,
87+ thisMonthFirstDay = jMoment ( year + '/' + ( month + 1 ) + '/1' , 'jYYYY/jM/jD' ) ,
88+ dayOfWeek = ( thisMonthFirstDay . weekday ( ) - 1 ) % 7 ,
9589 slotsAccumulator = 0 ;
9690
9791 for ( let i = 0 ; i < MAX_ROWS ; i ++ ) { // Week rows
9892 columns = [ ] ;
9993
10094 for ( let j = 0 ; j < MAX_COLUMNS ; j ++ ) { // Day columns
10195 if ( slotsAccumulator >= dayOfWeek ) {
102- if ( currentDay < moment . jDaysInMonth ( year , month ) ) {
96+ if ( currentDay < jMoment . jDaysInMonth ( year , month ) ) {
10397 columns . push ( < Day
10498 key = { j }
10599 day = { currentDay + 1 }
106100 selected = { this . state . selectedStates [ currentDay ] }
107- date = { moment ( year + '/' + ( month + 1 ) + '/' + ( currentDay + 1 ) , 'jYYYY/jM/jD' ) }
101+ date = { jMoment ( year + '/' + ( month + 1 ) + '/' + ( currentDay + 1 ) , 'jYYYY/jM/jD' ) }
108102 maxDate = { this . props . maxDate }
109103 minDate = { this . props . minDate }
110104 onDayChange = { this . onPressDay }
@@ -113,7 +107,7 @@ class Days extends React.Component {
113107 selectedDayTextColor = { this . props . selectedDayTextColor }
114108 textStyle = { this . props . textStyle } /> ) ;
115109 currentDay ++ ;
116- } else if ( currentDay >= moment . jDaysInMonth ( year , month ) ) {
110+ } else if ( currentDay >= jMoment . jDaysInMonth ( year , month ) ) {
117111 columns . push ( < Day
118112 key = { j }
119113 day = { '' }
0 commit comments