@@ -17,10 +17,13 @@ class TalkEventItemView @JvmOverloads constructor(
1717 defStyleAttr : Int = R .attr.cardViewDefaultStyle
1818) : EventItemView(context, attrs, defStyleAttr) {
1919
20- override fun updateWith (event : Event , showRoom : Boolean ) {
20+ private val timeFormatter = DateTimeFormat .shortTime()
21+ private val dateFormatter = DateTimeFormat .forPattern(" EEE d" )
22+
23+ override fun updateWith (event : Event , showRoom : Boolean , showDay : Boolean ) {
2124 ensureSupportedType(event.type)
2225
23- timestamp.text = startTimeAsFormattedString(event)
26+ timestamp.text = startTimeAsFormattedString(event, showDay )
2427 title.text = event.title
2528 room.apply {
2629 text = event.place.orNull().toPlaceLabel()
@@ -47,10 +50,14 @@ class TalkEventItemView @JvmOverloads constructor(
4750 }
4851 }
4952
50- private fun startTimeAsFormattedString (event : Event ): String {
51- val formatter = DateTimeFormat .shortTime()
52- .withZone(event.timeZone)
53+ private fun startTimeAsFormattedString (event : Event , showDay : Boolean ): String {
54+ val timeZone = event.timeZone
55+ val startDateTime = event.startTime.toDateTime(timeZone)
56+
57+ // Note: the space at the end of the template string is not a typo, it separates the date from the time
58+ val formattedDate = if (showDay) " ${dateFormatter.withZone(timeZone).print (startDateTime)} " else " "
59+ val formattedTime = timeFormatter.withZone(timeZone).print (startDateTime)
5360
54- return formatter. print (event.startTime.toDateTime())
61+ return " $formattedDate$formattedTime "
5562 }
5663}
0 commit comments