React-dates: some problems with "isDayHighlighted"

Created on 26 Sep 2017  路  2Comments  路  Source: airbnb/react-dates

Hi, There,

I'm trying to combine the isSame ( moment.js method ) & isDayHighlighted,
but some weird things happend.

  1. when i use "Array" into isSame, it's works fine :
    ( the format of Array must be [YYYY, MM, DD] )
    isDayHighlighted : day => day.isSame( [2017, 8, 30], 'day' )

  2. when i use "String" into isSame, but it's not working :
    ( the format of String must be 'YYYY-MM-DD' )
    isDayHighlighted : day => day.isSame( '2017-8-30' , 'day' )

either way is return true,
but the "String" way isn't working.
Does anyone knows why?

PS : isSame docs : http://momentjs.com/docs/#/query/is-same/

Thanks for help. ^^

Most helpful comment

This example will highlight today's date on the calendar:

const now = moment()
...
<SingleDatePicker
isDayHighlighted={ day => day.isSame( now, 'd' ) }
...
/>

All 2 comments

These seems like more of a moment question than a react-dates question, so I'm going to close this issue.

Um, in general, I'd recommend using the exported isSameDay method from this repo as its a bit more performant.

This example will highlight today's date on the calendar:

const now = moment()
...
<SingleDatePicker
isDayHighlighted={ day => day.isSame( now, 'd' ) }
...
/>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

AsasinCree picture AsasinCree  路  3Comments

swaritkohli picture swaritkohli  路  3Comments

aaronvanston picture aaronvanston  路  3Comments

arthurvi picture arthurvi  路  3Comments

sag1v picture sag1v  路  3Comments