Bimba.git

ref: cc07ea7272bb1fe1445d9398145f46669a01013e

app/src/main/java/ml/adamsprogs/bimba/extensions.kt


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package ml.adamsprogs.bimba

import ml.adamsprogs.bimba.models.Timetable
import java.util.*

internal fun Calendar.getMode(): String {
    return when (this.get(Calendar.DAY_OF_WEEK)) {
        Calendar.SUNDAY -> Timetable.MODE_SUNDAYS
        Calendar.SATURDAY -> Timetable.MODE_SATURDAYS
        else -> Timetable.MODE_WORKDAYS
    }
}

internal fun String.toPascalCase(): String { //check
    val builder = StringBuilder(this)
    var isLastCharSeparator = true
    builder.forEach {
        isLastCharSeparator = if ((it in 'a'..'z' || it in 'A'..'Z') && isLastCharSeparator){
            it.toUpperCase()
            false
        } else
            true
    }
    return builder.toString()
}