2019-04-24 18:28:41 +00:00
|
|
|
package com.topjohnwu.magisk.utils
|
|
|
|
|
2019-05-09 15:01:34 +00:00
|
|
|
import java.text.DateFormat
|
2019-04-24 18:28:41 +00:00
|
|
|
import java.text.ParseException
|
|
|
|
import java.text.SimpleDateFormat
|
|
|
|
|
|
|
|
val now get() = System.currentTimeMillis()
|
|
|
|
|
2019-05-09 15:01:34 +00:00
|
|
|
fun Long.toTime(format: DateFormat) = format.format(this).orEmpty()
|
|
|
|
fun String.toTime(format: DateFormat) = try {
|
2019-04-24 18:28:41 +00:00
|
|
|
format.parse(this)?.time ?: -1
|
|
|
|
} catch (e: ParseException) {
|
|
|
|
-1L
|
|
|
|
}
|
|
|
|
|
2019-05-10 14:41:31 +00:00
|
|
|
private val locale get() = LocaleManager.locale
|
2019-05-07 13:41:56 +00:00
|
|
|
val timeFormatFull by lazy { SimpleDateFormat("yyyy/MM/dd_HH:mm:ss", locale) }
|
2019-05-09 15:01:34 +00:00
|
|
|
val timeFormatStandard by lazy { SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", locale) }
|
|
|
|
val timeFormatMedium by lazy { DateFormat.getDateInstance(DateFormat.MEDIUM, LocaleManager.locale) }
|
|
|
|
val timeFormatTime by lazy { SimpleDateFormat("h:mm a", LocaleManager.locale) }
|