123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- //
- // IHUtil.swift
- // Inhealth
- //
- // Created by weclouds on 2019/12/11.
- // Copyright © 2019 weclouds. All rights reserved.
- //
- import UIKit
- enum Period {
- case normal
- case morning
- case afternoon
- case evening
- }
- class IHUtil: NSObject {
- static let share = IHUtil()
- //获取当前时间点
- func currentPeriod() -> Period {
- let dateformatter = DateFormatter()
- dateformatter.dateFormat = "HH"// 自定义时间格式
- // GMT时间 转字符串,直接是系统当前时间
- let timeStr = dateformatter.string(from: Date())
- let hour = Int(timeStr)
-
- if let aHour = hour {
- if aHour > 4 && aHour <= 10 {
- return .morning
- }else if aHour > 10 && aHour <= 18 {
- return .afternoon
- }else if aHour > 18 && aHour <= 24 {
- return .evening
- }else{
- return .normal
- }
- }else{
- return .normal
- }
- }
-
- }
|