package com.xyzshell.myphoneinfo.custom

object SetNumberOrWordUtils {
    fun setDecimal1(double: Double): String{
        return "%.1f".format(double)
    }
    fun setDecimal0(double: Double): String{
        return  double.toInt().toString()
    }

    fun toTitleCase(sentence: String): String {
        if (sentence.isEmpty()) return ""

        val words = sentence.trim().split("\\s+".toRegex())  // 按一个或多个空格分割

        return if (words.isNotEmpty()) {
            // 第一个单词首字母大写
            val firstWord = words[0].lowercase().replaceFirstChar { it.uppercase() }

            // 其余单词保持小写
            val remainingWords = words.drop(1).joinToString(" ") { it.lowercase() }

            if (remainingWords.isNotEmpty()) {
                "$firstWord $remainingWords"
            } else {
                firstWord
            }
        } else {
            ""
        }
    }
}