File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
core/src/main/java/com/example/util/simpletimetracker/core/extension Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -22,10 +22,17 @@ fun Record.isNotFiltered(filter: TypesFilterParams): Boolean {
2222}
2323
2424fun Calendar.setWeekToFirstDay () {
25- val currentTime = timeInMillis
26- set(Calendar .DAY_OF_WEEK , firstDayOfWeek)
25+ val another = Calendar .getInstance()
26+ another.timeInMillis = timeInMillis
27+
28+ val currentTime = another.timeInMillis
29+ // Setting DAY_OF_WEEK have a weird behaviour so as if after that another field is set -
30+ // it would reset to current day. Use another calendar to manipulate day of week and get its time.
31+ another.set(Calendar .DAY_OF_WEEK , firstDayOfWeek)
2732 // If went to future - go back a week
28- if (timeInMillis > currentTime) {
29- add(Calendar .DATE , - 7 )
33+ if (another. timeInMillis > currentTime) {
34+ another. add(Calendar .DATE , - 7 )
3035 }
36+
37+ timeInMillis = another.timeInMillis
3138}
You can’t perform that action at this time.
0 commit comments