Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set initialTab based on current date. #98

Merged
merged 1 commit into from
Apr 20, 2022

Conversation

oldergod
Copy link
Contributor

fixes #95

val dayOfYear = Instant.ofEpochMilli(dayInMillis).atZone(ZoneId.systemDefault()).dayOfYear
todayOfYear == dayOfYear
}
return if (todayPageIndex < 0) 0 else todayPageIndex
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Time is hard 😅 . Do we really need to go through timezones here since will have epochMillis everywhere? Maybe something like:

private fun List<DaySchedule>.todayPageIndex(): Int{
    val todayPageIndex = indexOfLast { (dayInMillis, _, _) ->
        System.currentTimeMillis() >= dayInMillis
    }
    return if (todayPageIndex < 0) 0 else todayPageIndex
}

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

val dayInMillis: Long,
Copy link
Contributor

@martinbonnin martinbonnin Apr 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super nit: I kind of like ultra long descriptive names for those like dayStartEpochMilli.
Actually, I'd like to rename a lot of the time, timestamp we have to fooEpochMilli. That would make it more explicit what the reference point and unit is.
But dayInMillis works too so feel free to ignore my time ramblings!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@oldergod oldergod force-pushed the bquenaudon.2022-04-19.defaulttab branch from 6640e1a to c07cb8a Compare April 19, 2022 23:30
Copy link
Contributor

@martinbonnin martinbonnin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 💚 !

@martinbonnin martinbonnin merged commit 487f4d8 into paug:main Apr 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default opened tab should match the date.
2 participants