Move extensions to its own package

This commit is contained in:
topjohnwu
2019-07-28 02:10:22 -07:00
parent 42e7db8d13
commit d1ff7e0ffe
59 changed files with 91 additions and 77 deletions
@@ -0,0 +1,21 @@
package com.topjohnwu.magisk.extensions
import com.topjohnwu.magisk.utils.LocaleManager
import java.text.DateFormat
import java.text.ParseException
import java.text.SimpleDateFormat
val now get() = System.currentTimeMillis()
fun Long.toTime(format: DateFormat) = format.format(this).orEmpty()
fun String.toTime(format: DateFormat) = try {
format.parse(this)?.time ?: -1
} catch (e: ParseException) {
-1L
}
private val locale get() = LocaleManager.locale
val timeFormatFull by lazy { SimpleDateFormat("yyyy/MM/dd_HH:mm:ss", locale) }
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) }