Global date formatter.
This commit is contained in:
parent
f4f8503037
commit
9b372a45ce
@ -109,7 +109,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
||||
private var periodicRefresh = false
|
||||
private var refreshMinutes: Long = 360L
|
||||
private var refreshWhenChargingOnly = false
|
||||
private var dateTimeFormatter = "yyyy-MM-dd HH:mm:ss"
|
||||
|
||||
private lateinit var tabNewBadge: TextBadgeItem
|
||||
private lateinit var tabArchiveBadge: TextBadgeItem
|
||||
|
@ -18,6 +18,8 @@ import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader
|
||||
import com.mikepenz.materialdrawer.util.DrawerImageLoader
|
||||
import java.util.UUID.randomUUID
|
||||
|
||||
var dateTimeFormatter = "yyyy-MM-dd HH:mm:ss"
|
||||
|
||||
class MyApp : MultiDexApplication() {
|
||||
private lateinit var config: Config
|
||||
|
||||
|
@ -4,6 +4,7 @@ import android.content.Context
|
||||
import android.text.format.DateUtils
|
||||
import apps.amine.bou.readerforselfoss.api.selfoss.Item
|
||||
import apps.amine.bou.readerforselfoss.api.selfoss.SelfossTagType
|
||||
import apps.amine.bou.readerforselfoss.dateTimeFormatter
|
||||
import java.text.ParseException
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
@ -21,14 +22,8 @@ fun String.toTextDrawableString(c: Context): String {
|
||||
|
||||
fun Item.sourceAndDateText(): String {
|
||||
val formattedDate: String = try {
|
||||
var date = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(this.datetime)
|
||||
// Api 3.0 changes the date format, check for ISO8601 format
|
||||
if (date == null) {
|
||||
date = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX").parse(this.datetime)
|
||||
}
|
||||
|
||||
" " + DateUtils.getRelativeTimeSpanString(
|
||||
date.time,
|
||||
SimpleDateFormat(dateTimeFormatter).parse(this.datetime).time,
|
||||
Date().time,
|
||||
DateUtils.MINUTE_IN_MILLIS,
|
||||
DateUtils.FORMAT_ABBREV_RELATIVE
|
||||
|
Loading…
Reference in New Issue
Block a user