Skip to content

Commit 3a4d73b

Browse files
committed
#226: time formatting improvements
1 parent 3c68810 commit 3a4d73b

5 files changed

Lines changed: 15 additions & 5 deletions

File tree

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package models.data
22

33
import java.time.ZonedDateTime
4+
import java.time.format.DateTimeFormatter
45

5-
case class FeedItem(time: ZonedDateTime, title: String, description: String, link: String, guid: String)
6+
case class FeedItem(time: ZonedDateTime, title: String, description: String, link: String, guid: String) {
7+
def rfcFormattedTime: String = {
8+
time.format(DateTimeFormatter.RFC_1123_DATE_TIME)
9+
}
10+
}

scalajvm/app/models/data/Quote.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
package models.data
22

33
import java.time.ZonedDateTime
4+
import java.time.format.DateTimeFormatter
45

56
import scalikejdbc._
67

7-
case class Quote(id: Long, source: String, sourceUrl: Option[String], time: ZonedDateTime, content: Option[String], rating: Int)
8+
case class Quote(id: Long, source: String, sourceUrl: Option[String], time: ZonedDateTime, content: Option[String], rating: Int) {
9+
def formattedTime: String =
10+
time.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME)
11+
}
12+
813
object Quote extends SQLSyntaxSupport[Quote] {
914
override val tableName = "quote"
1015

scalajvm/app/views/index.scala.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<span><a href="@routes.Quotes.quote(quote.id)">#@quote.id</a></span>
5353
<span class="desktop-only">@voting.ratingPanel(quote)</span>
5454
</div>
55-
<span>@quote.time</span>
55+
<span>@quote.formattedTime</span>
5656
</div>
5757
<div class="quote-content plate">@quote.content.getOrElse("")</div>
5858
@(quote.source, quote.sourceUrl) match {

scalajvm/app/views/quote.scala.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<span><a href="@quote.id">#@quote.id</a></span>
1111
<span class="desktop-only">@voting.ratingPanel(quote)</span>
1212
</div>
13-
<span>@quote.time</span>
13+
<span>@quote.formattedTime</span>
1414
</div>
1515
<div class="quote-content plate">@quote.content.getOrElse("")</div>
1616
@(quote.source, quote.sourceUrl) match {

scalajvm/app/views/rssFeed.scala.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<link>@item.link</link>
1717
<guid>@item.guid</guid>
1818
<description>@item.description</description>
19-
<pubDate>@item.time</pubDate>
19+
<pubDate>@item.rfcFormattedTime</pubDate>
2020
</item>
2121
}
2222
</channel>

0 commit comments

Comments
 (0)