Skip to content

Commit

Permalink
UTC Calendar fix
Browse files Browse the repository at this point in the history
  • Loading branch information
foralost committed Feb 25, 2024
1 parent ab86cee commit 69d3076
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,24 @@ class DateUtilsTest : BaseUnitTest() {
assertThat(arrayOf("Sat", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri"), equalTo(longWeekdayNames))
}

private fun getCalendarUTC(year : Int, month : Int, dayOfMonth : Int) : GregorianCalendar {
val gregCalendar = GregorianCalendar(year, month, dayOfMonth)
gregCalendar.timeZone = TimeZone.getTimeZone("UTC");
return gregCalendar
}
@Test
fun getWeekdaysInMonth() {
val february = GregorianCalendar(2018, Calendar.FEBRUARY, 1)
val leapFebruary = GregorianCalendar(2020, Calendar.FEBRUARY, 1)
val month = GregorianCalendar(2020, Calendar.APRIL, 1)
val longMonth = GregorianCalendar(2020, Calendar.AUGUST, 1)

val february = getCalendarUTC(2018, Calendar.FEBRUARY, 1)
val leapFebruary = getCalendarUTC(2020, Calendar.FEBRUARY, 1)
val month = getCalendarUTC(2020, Calendar.APRIL, 1)
val longMonth = getCalendarUTC(2020, Calendar.AUGUST, 1)

assertThat(
arrayOf(4, 4, 4, 4, 4, 4, 4),
equalTo(DateUtils.getWeekdaysInMonth(Timestamp(february)))
)

assertThat(
arrayOf(5, 4, 4, 4, 4, 4, 4),
equalTo(DateUtils.getWeekdaysInMonth(Timestamp(leapFebruary)))
Expand Down

0 comments on commit 69d3076

Please sign in to comment.