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

[FIX] calendar error #124

Merged
merged 2 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(ActivityMainBinding::infl
holder.binding.weekCardview.setBackgroundResource(R.drawable.ic_selector_background_white)
holder.binding.day.isSelected = false
holder.binding.date.isSelected = false
if (holder.today.equals(data.cl_date)) {
if (holder.today == data.cl_date) {
holderSelect = holder
selected = holder.today
}
Expand Down
25 changes: 17 additions & 8 deletions app/src/main/java/com/eatssu/android/ui/main/menu/MenuFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import java.time.DayOfWeek
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import java.time.temporal.TemporalAdjusters
import java.util.Locale

class MenuFragment : Fragment() {
private var _binding: FragmentMenuBinding? = null
Expand Down Expand Up @@ -101,14 +103,21 @@ class MenuFragment : Fragment() {

// ViewModel에서 데이터 가져오기
calendarViewModel.getData().observe(viewLifecycleOwner) { dataReceived ->
if (dataReceived.toInt() < 7) {
val nextMonthDate = LocalDateTime.now().plusMonths(1)
val nextMonth = nextMonthDate.format(DateTimeFormatter.ofPattern("yyyyMM"))
menuDate = "$nextMonth$dataReceived"
}
else {
menuDate =
LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMM")) + dataReceived

val preSunday: LocalDateTime = LocalDateTime.now().with(
TemporalAdjusters.previousOrSame(
DayOfWeek.SUNDAY
)
)

val dateFormat =
DateTimeFormatter.ofPattern("dd").withLocale(Locale.forLanguageTag("ko"))
val fullFormat = DateTimeFormatter.ofPattern("yyyyMMdd").withLocale(Locale.forLanguageTag("ko"))

for (i in 0..6) {
if (preSunday.plusDays(i.toLong()).format(dateFormat) == dataReceived) {
menuDate = preSunday.plusDays(i.toLong()).format(fullFormat)
}
}

Log.d("menucalendar", menuDate)
Expand Down
Loading