adding an option to show current year too

This commit is contained in:
tibbi 2021-02-16 13:22:57 +01:00
parent 48c56624b1
commit c5cc2fd57d
2 changed files with 3 additions and 3 deletions

View file

@ -6,7 +6,7 @@ buildscript {
propMinSdkVersion = 21
propTargetSdkVersion = propCompileSdkVersion
propVersionCode = 1
propVersionName = '5.33.31'
propVersionName = '5.33.32'
kotlin_version = '1.4.30'
}

View file

@ -62,7 +62,7 @@ fun Int.formatDate(context: Context, dateFormat: String? = null, timeFormat: Str
}
// if the given date is today, we show only the time. Else we show the date and optionally the time too
fun Int.formatDateOrTime(context: Context, hideTimeAtOtherDays: Boolean): String {
fun Int.formatDateOrTime(context: Context, hideTimeAtOtherDays: Boolean, showYearEvenIfCurrent: Boolean): String {
val cal = Calendar.getInstance(Locale.ENGLISH)
cal.timeInMillis = this * 1000L
@ -70,7 +70,7 @@ fun Int.formatDateOrTime(context: Context, hideTimeAtOtherDays: Boolean): String
DateFormat.format(context.getTimeFormat(), cal).toString()
} else {
var format = context.baseConfig.dateFormat
if (isThisYear()) {
if (!showYearEvenIfCurrent && isThisYear()) {
format = format.replace("y", "").trim().trim('-').trim('.').trim('/')
}