From 41a20e4e8124ccae0834ceb534e35b360777256b Mon Sep 17 00:00:00 2001 From: hamednn76 Date: Mon, 12 Aug 2019 15:35:24 +0430 Subject: [PATCH 1/2] add friday and holiday day color to calendar --- package.json | 1 + src/Day.js | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index ba0290c..abffb56 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ }, "dependencies": { "moment-jalaali": "^0.7.4", + "pholiday": "^0.2.1", "prop-types": "^15.7.2", "react-native-common": "^1.8.2", "uuid": "3.2.1" diff --git a/src/Day.js b/src/Day.js index d425d11..fafb570 100644 --- a/src/Day.js +++ b/src/Day.js @@ -11,6 +11,7 @@ const React = require('react'); const PropTypes = require('prop-types'); const jMoment = require('moment-jalaali'); const { Text, TouchableOpacity, View } = require('react-native'); +const pholiday = require('pholiday'); function Day(props) { const { @@ -227,11 +228,24 @@ function Day(props) { } } + const isHoliday = pholiday( + `${year}/${Number(month) + 1}/${day}`, + 'jYYYY/jM/jD', + ) + .events()x + .find(event => event.isHoliday); + const holidayStyle = isHoliday ? { backgroundColor: 'red' } : {}; + return ( onPressDay(day)} > Date: Mon, 12 Aug 2019 15:38:43 +0430 Subject: [PATCH 2/2] . --- src/Day.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Day.js b/src/Day.js index fafb570..a846cd9 100644 --- a/src/Day.js +++ b/src/Day.js @@ -232,7 +232,7 @@ function Day(props) { `${year}/${Number(month) + 1}/${day}`, 'jYYYY/jM/jD', ) - .events()x + .events() .find(event => event.isHoliday); const holidayStyle = isHoliday ? { backgroundColor: 'red' } : {};