From 6be237f1454ce752bb9937163f1d0d1d7c4cfb7e Mon Sep 17 00:00:00 2001 From: hoangnm Date: Tue, 21 May 2019 22:27:16 +0700 Subject: [PATCH] move some functions to utils --- src/Header/Header.js | 13 ++----------- src/utils.js | 9 +++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) create mode 100644 src/utils.js diff --git a/src/Header/Header.js b/src/Header/Header.js index 798fafb9..6025fda6 100644 --- a/src/Header/Header.js +++ b/src/Header/Header.js @@ -3,8 +3,9 @@ import PropTypes from 'prop-types'; import { Text, View } from 'react-native'; import moment from 'moment'; -import styles from './Header.styles'; +import { getFormattedDate, getCurrentMonth } from '../utils'; +import styles from './Header.styles'; const getBorder = (items, index) => { return { @@ -28,14 +29,6 @@ const getColumns = (numberOfDays, selectedDate) => { return columns; }; -const getFormattedDate = (date, format) => { - return moment(date).format(format); -}; - -const getCurrentMonth = (date) => { - return moment(date).format('MMMM Y'); -}; - const getFontSizeHeader = (numberOfDays) => { if (numberOfDays > 1) { return 12; @@ -51,8 +44,6 @@ const getDayTextStyles = (numberOfDays) => { }; }; -// components - const Column = ({ column, style, numberOfDays, format }) => { return ( diff --git a/src/utils.js b/src/utils.js new file mode 100644 index 00000000..0e635d67 --- /dev/null +++ b/src/utils.js @@ -0,0 +1,9 @@ +import moment from 'moment'; + +export const getFormattedDate = (date, format) => { + return moment(date).format(format); +}; + +export const getCurrentMonth = (date) => { + return moment(date).format('MMMM Y'); +}; \ No newline at end of file