Skip to content

Commit 04aea39

Browse files
committed
2 parents 3a7cbcc + da9eb52 commit 04aea39

3 files changed

Lines changed: 10 additions & 42 deletions

File tree

PennMobile/src/main/java/com/pennapps/labs/pennmobile/DiningInfoFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class DiningInfoFragment : Fragment() {
107107
layparamtimes.addRule(RelativeLayout.ALIGN_BOTTOM, vertical.last().id)
108108
layparamtimes.setMargins(0, 10, 0, 0)
109109
val mealInt = TextView(mActivity)
110-
val hoursString = meal.open?.let { meal.getFormattedHourZ(it) } + " - " + meal.close?.let { meal.getFormattedHourZ(it) }
110+
val hoursString = meal.open?.let { meal.getFormattedHour(it) } + " - " + meal.close?.let { meal.getFormattedHour(it) }
111111
mealInt.text = hoursString
112112
mealInt.id = vertical.last().id + 1
113113
menuParent.addView(mealInt, layparamtimes)

PennMobile/src/main/java/com/pennapps/labs/pennmobile/HomeFragment.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class HomeFragment : Fragment() {
164164
}
165165
}, { throwable ->
166166
mActivity.runOnUiThread {
167-
Log.e("Home", "Could not load Home page", throwable)
167+
Log.e("Home", "Could not load Dining", throwable)
168168
throwable.printStackTrace()
169169
loadingPanel?.visibility = View.GONE
170170
home_refresh_layout?.isRefreshing = false
@@ -180,7 +180,7 @@ class HomeFragment : Fragment() {
180180
val gsrBookingCell = HomeCell()
181181
gsrBookingCell.type = "gsr_booking"
182182
gsrBookingCell.buildings = arrayListOf("Huntsman Hall", "Weigle")
183-
homepageCells.set(3, gsrBookingCell)
183+
homepageCells.set(4, gsrBookingCell)
184184
home_cells_rv?.adapter = HomeAdapter(ArrayList(homepageCells))
185185
loadingPanel?.visibility = View.GONE
186186
home_refresh_layout?.isRefreshing = false

PennMobile/src/main/java/com/pennapps/labs/pennmobile/classes/VenueInterval.kt

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ class VenueInterval {
4949
var closeTime = "$date $close"
5050
// Avoid midnight hour confusion as API returns both 00:00 and 24:00
5151
// Switch it to more comprehensible 23:59 / 11:59PM
52-
if (close == "00:00:00Z" || close == "24:00:00Z") {
53-
closeTime = "$date 23:59:59Z"
52+
if (close == "00:00:00" || close == "24:00:00") {
53+
closeTime = "$date 23:59:59"
5454
}
5555
Log.i("VenueInterval", "$openTime")
5656
if (open == "" && close == "") {
57-
open ="00:00:00Z"
58-
close ="00:00:00Z"
57+
open ="00:00:00"
58+
close ="00:00:00"
5959
openTime = "$date $open"
6060
closeTime = "$date $close"
6161
}
@@ -64,7 +64,7 @@ class VenueInterval {
6464
try {
6565
closeInstant = DateTime.parse(closeTime, dateFormat)
6666
} catch (e: IllegalInstantException) {
67-
closeTime = "$date 01:00:00Z"
67+
closeTime = "$date 01:00:00"
6868
closeInstant = DateTime.parse(closeTime, dateFormat)
6969
}
7070

@@ -73,13 +73,7 @@ class VenueInterval {
7373
if (closeInstant.hourOfDay < 6) {
7474
closeInstant = closeInstant.plusDays(1)
7575
}
76-
try {
77-
return Interval(openInstant, closeInstant)
78-
} catch (e: Exception) {
79-
Log.e("VenueInterval", "Error creating interval", e)
80-
closeInstant = closeInstant.plusHours(24)
81-
return Interval(openInstant, closeInstant)
82-
}
76+
return Interval(openInstant, closeInstant)
8377
}
8478

8579
fun getFormattedHour(hours: String): String {
@@ -103,38 +97,12 @@ class VenueInterval {
10397

10498
}
10599

106-
fun getFormattedHourZ(hours: String): String {
107-
try {
108-
var newHours = hours.substring(0, 5)
109-
var hour = hours.substring(0, 2).toInt() - 5
110-
if(hour < 0) {
111-
hour += 24
112-
}
113-
if (hour > 12) {
114-
newHours = "" + (hour - 12) + hours.substring(2, 5)
115-
} else {
116-
newHours = "" + hour + hours.substring(2, 5)
117-
}
118-
newHours += if (hour >= 12) {
119-
"pm"
120-
} else {
121-
"am"
122-
}
123-
return newHours
124-
125-
} catch (exception: Exception) {
126-
Log.d("Time Formatting Error", exception.message ?: "")
127-
return hours
128-
}
129-
130-
}
131-
132100
companion object {
133101
/**
134102
* Date format used by dining API.
135103
* Example: "2015-08-10 15:00:00"
136104
*/
137-
val dateFormat: DateTimeFormatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ssZ")
105+
val dateFormat: DateTimeFormatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss")
138106
}
139107
}
140108
}

0 commit comments

Comments
 (0)