forked from hanse/react-calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
49 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import moment from 'moment'; | ||
|
||
export function getInitialDate (props) { | ||
// NOTE: there is DEFAUT_DATE and DATE | ||
// TODO: leave only one date DEFAUT_DATE or DATE | ||
return props.DATE_CURRENT ? moment(props.DATE_CURRENT) : moment(); | ||
} | ||
|
||
export function parseSelects (props) { | ||
let internalSelects = {}; | ||
if (props.DATE_SELECTS) { | ||
props.DATE_SELECTS.forEach(select => { | ||
let ymd = moment(select.DATE).format('YYYY-MM-DD'); | ||
internalSelects[ymd] = select.CLASSNAME; | ||
}); | ||
} | ||
return internalSelects; | ||
} | ||
|
||
export function isAbleToScrollLeft (props, currentMoment) { | ||
if (props.DATE_MIN) { | ||
return currentMoment.isAfter(props.DATE_MIN, 'month'); | ||
} else { | ||
return true; | ||
} | ||
} | ||
|
||
export function isAbleToScrollRigtht (props, currentMoment) { | ||
if (props.UI_MONTHS_NUMBER && props.UI_MONTHS_NUMBER > 1) { | ||
currentMoment = currentMoment.clone().add( | ||
props.UI_MONTHS_NUMBER - 1, 'month'); | ||
} | ||
if (props.DATE_MAX) { | ||
return currentMoment.isBefore(props.DATE_MAX, 'month'); | ||
} else { | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters