Skip to content

Commit 6c82dd5

Browse files
authored
fix: convert to local date before passing current date to the next view (#869)
* fix: convert to local date before passing current date to the next view * docs: update changelog Refs: #45
1 parent 776dbf5 commit 6c82dd5

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
### Changed
99
- Updated holiday data
1010

11+
### Fixed
12+
- Fixed incorrect weekly view start date in some cases ([#45])
13+
1114
## [1.8.0] - 2025-10-29
1215
### Changed
1316
- Compatibility updates for Android 15 & 16
@@ -150,6 +153,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
150153
- Initial release
151154

152155
[#34]: https://github.com/FossifyOrg/Calendar/issues/34
156+
[#45]: https://github.com/FossifyOrg/Calendar/issues/45
153157
[#49]: https://github.com/FossifyOrg/Calendar/issues/49
154158
[#135]: https://github.com/FossifyOrg/Calendar/issues/135
155159
[#138]: https://github.com/FossifyOrg/Calendar/issues/138

app/src/main/kotlin/org/fossify/calendar/activities/MainActivity.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import org.fossify.calendar.helpers.FETCH_INTERVAL
5151
import org.fossify.calendar.helpers.FLAG_ALL_DAY
5252
import org.fossify.calendar.helpers.FLAG_MISSING_YEAR
5353
import org.fossify.calendar.helpers.Formatter
54+
import org.fossify.calendar.helpers.Formatter.DAYCODE_PATTERN
5455
import org.fossify.calendar.helpers.HOLIDAY_EVENT
5556
import org.fossify.calendar.helpers.HolidayHelper
5657
import org.fossify.calendar.helpers.INITIAL_EVENTS
@@ -1047,8 +1048,14 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
10471048
}
10481049

10491050
private fun fixDayCode(dayCode: String? = null): String? = when {
1050-
config.storedView == WEEKLY_VIEW && (dayCode?.length == Formatter.DAYCODE_PATTERN.length) -> getFirstDayOfWeek(Formatter.getDateTimeFromCode(dayCode))
1051-
config.storedView == YEARLY_VIEW && (dayCode?.length == Formatter.DAYCODE_PATTERN.length) -> Formatter.getYearFromDayCode(dayCode)
1051+
config.storedView == WEEKLY_VIEW && (dayCode?.length == DAYCODE_PATTERN.length) -> {
1052+
getFirstDayOfWeek(Formatter.getLocalDateTimeFromCode(dayCode))
1053+
}
1054+
1055+
config.storedView == YEARLY_VIEW && (dayCode?.length == DAYCODE_PATTERN.length) -> {
1056+
Formatter.getYearFromDayCode(dayCode)
1057+
}
1058+
10521059
else -> dayCode
10531060
}
10541061

app/src/main/kotlin/org/fossify/calendar/fragments/DayFragmentsHolder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class DayFragmentsHolder : MyFragmentHolder(), NavigationListener {
139139

140140
override fun getCurrentDate(): DateTime? {
141141
return if (currentDayCode != "") {
142-
Formatter.getDateTimeFromCode(currentDayCode)
142+
Formatter.getLocalDateTimeFromCode(currentDayCode)
143143
} else {
144144
null
145145
}

app/src/main/kotlin/org/fossify/calendar/fragments/MonthDayFragmentsHolder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class MonthDayFragmentsHolder : MyFragmentHolder(), NavigationListener {
145145

146146
override fun getCurrentDate(): DateTime? {
147147
return if (currentDayCode != "") {
148-
DateTime(Formatter.getDateTimeFromCode(currentDayCode).toString())
148+
Formatter.getLocalDateTimeFromCode(currentDayCode)
149149
} else {
150150
null
151151
}

app/src/main/kotlin/org/fossify/calendar/fragments/MonthFragmentsHolder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class MonthFragmentsHolder : MyFragmentHolder(), NavigationListener {
144144

145145
override fun getCurrentDate(): DateTime? {
146146
return if (currentDayCode != "") {
147-
DateTime(Formatter.getDateTimeFromCode(currentDayCode).toString())
147+
Formatter.getLocalDateTimeFromCode(currentDayCode)
148148
} else {
149149
null
150150
}

0 commit comments

Comments
 (0)