//
获取当前日期
let
moonDay =
Date
().
stringWithFormatterL
(dateFormat:
“M
月
dd
日
”
)
let
time =
Date
().
stringWithFormatterL
(dateFormat:
“HH:mm”
)
let
weekDay =
Date
().
weekDay
()
DLog
(
”
\
(
moonDay
)——
\
(
time
)——
\
(
weekDay
)”
)
//
获取星期几
func
weekDay() ->
String
{
let
weekDays = [
NSNull
.
init
(),
”
周日
”
,
”
周一
”
,
”
周二
”
,
”
周三
”
,
”
周四
”
,
”
周五
”
,
”
周六
”
]
as
[
Any
]
let
calendar =
NSCalendar
.
init
(calendarIdentifier: .
gregorian
)
let
timeZone =
NSTimeZone
.
init
(name:
“Asia/Shanghai”
)
calendar?.
timeZone
= timeZone
as
!
TimeZone
let
calendarUnit =
NSCalendar
.
Unit
.
weekday
let
theComponents = calendar?.
components
(calendarUnit, from:
self
)
return
weekDays[(theComponents?.
weekday
)!]
as
!
String
}