package com.base.browserwhite.help

import android.annotation.SuppressLint
import java.text.SimpleDateFormat
import java.util.Calendar

object TimeUtils {

    fun isDayOrNight(): Boolean {
        val calendar: Calendar = Calendar.getInstance()
        val hour: Int = calendar.get(Calendar.HOUR_OF_DAY)
        // 假设早上6点到晚上6点是白天
        return if (hour in 6..17) {
//            "现在是白天。"
            true
        } else {
//            "现在是晚上。"
            false
        }
    }

    @SuppressLint("SimpleDateFormat")
    fun formatATime(): String {
        val calendar = Calendar.getInstance()
        // 格式化时间为 "AM 9:50" 格式
        val sdf = SimpleDateFormat("a hh:mm")
        return sdf.format(calendar.time)
    }
}