rghorbani / react-native-general-calendars

React Native Calendar Components 📆
MIT License
94 stars 16 forks source link

jalaali wrong result #24

Open sm2017 opened 5 years ago

sm2017 commented 5 years ago

@rghorbani type="gregorian" works well but , jalaali is not

<Calendar
  type="jalaali"
  onDayPress={(day, localDay) => {console.log('selected day', day.dateString, localDay.dateString)}}
  onDayLongPress={(day, localDay) => {console.log('selected day', day.dateString, localDay.dateString)}}
/>

logged console is :

selected day ۰۶۲۱-۰۳-۲۱ ۰۰۰۰-۰۱-۰۱
saeedkargosha commented 5 years ago

I had the same error But I fixed it with usePersianDigits: false

import fa from 'moment/locale/fa';
import en from 'moment/locale/en-gb'
import jmoment from "moment-jalaali";
if(lang === 'fa'){
   jmoment.locale("fa", fa);
   jmoment.loadPersian({usePersianDigits: false, dialect: 'persian-modern'})
} else {
   jmoment.loadPersian({usePersianDigits: false})
   jmoment.locale('en', en)
}