<?PHP
defined(
'TSKY'
) || die(
'Permission Denied!'
);
function fmtMonth($month){
return
date(
'F, Y'
,day2time($month.
'01'
));
}
function fmt_month($ts) {
return
strftime(
"%b,%Y"
,$ts);
}
function shartTime($ts) {
return
strftime(
"%H:%M"
,$ts);
}
function longTime($ts) {
return
strftime(
"%T"
,$ts);
}
function shortDate($ts) {
return
date(
"n月d日"
,$ts);
}
function longDate($ts) {
return
date(
"Y年n月d日"
,$ts);
}
function dateTime($ts) {
return
date(
"Y年n月d日 H:i:s"
,$ts);
}
function fullDateTime($ts) {
return
date(
"Y年n月d日 "
,$ts).week($ts);
}
function week($ts) {
global $lang;
return
$lang[
'weekDay'
][date(
'w'
,$ts)];
}
function relatively_date($date) {
if
(!preg_match(
'/^\d+$/'
, $date)) $date = strtotime(trim($date));
$sec = time() - $date;
switch
(
true
){
case
$sec < 3600:
return
round($sec/60).
' 分钟前'
;
case
$sec < 86400:
return
round($sec/3600).
' 小时前'
;
case
$sec < (86400 * 7):
return
round($sec/86400).
' 天前'
;
case
$sec < (86400 * 7 * 4):
return
round($sec/(86400*7)).
' 周前'
;
default
:
return
longDate($date);
}
}
function nextMonth($month
){
return
date(
'Ym'
,strtotime(
'+1 month'
,strtotime($month.
'01'
)));
}
function prevMonth($month
){
return
date(
'Ym'
,strtotime(
'-1 month'
,strtotime($month.
'01'
)));
}
function prevDay($day
){
$day = substr($day,0,8);
return
date(
'Ymd'
,strtotime(
'-1 day'
,strtotime($day)));
}
function nextDay($day
){
$day = substr($day,0,8);
return
date(
'Ymd'
,strtotime(
'+1 day'
,strtotime($day)));
}
function nextExistsDay($day
){
$day = nextDay($day);
while
(!hasTopic($day) && $day < TODAY){
$day = nextDay($day);
}
return
hasTopic($day) ? $day :
false
;
}
function prevExistsDay($day
){
global $cfg;
$day = prevDay($day);
while
(!hasTopic($day) && (
int
)$day > $cfg->origDate){
$day = prevDay($day);
}
return
hasTopic($day) ? $day :
false
;
}
function prev_day($day){$day = substr($day,0,8);
return
date(
'Ymd'
,strtotime(
'-1 day'
,strtotime($day)));}
function long_date($ts){
return
date(
"Y年n月d日"
,$ts);}
function day2time($day){
return
@strtotime($day);}