开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
1 Star 0 Fork 921

张健(peter)/IBOS

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (2)
标签 (6)
master
develop
4.2
3.9
3.8
3.5
v3.5
3.3
master
分支 (2)
标签 (6)
master
develop
4.2
3.9
3.8
3.5
v3.5
3.3
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (2)
标签 (6)
master
develop
4.2
3.9
3.8
3.5
v3.5
3.3
IBOS
/
library
/
utils
/
CTimestamp.php
IBOS
/
library
/
utils
/
CTimestamp.php
CTimestamp.php 10.26 KB
一键复制 编辑 原始数据 按行查看 历史
seekArt 提交于 2015年07月21日 17:24 +08:00 . 提交初始版本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376
<?php
/**
* CTimestamp class file.
*
* @author Wei Zhuo <weizhuo[at]gamil[dot]com>
* @link http://www.yiiframework.com/
* @copyright 2008-2013 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
/**
* CTimestamp represents a timestamp.
*
* Part of this class was adapted from the ADOdb Date Library
* {@link http://phplens.com/phpeverywhere/ ADOdb abstraction library}.
* The original source code was released under both BSD and GNU Lesser GPL
* library license, with the following copyright notice:
* Copyright (c) 2000, 2001, 2002, 2003, 2004 John Lim
* All rights reserved.
*
* This class is provided to support UNIX timestamp that is beyond the range
* of 1901-2038 on Unix and1970-2038 on Windows. Except {@link getTimestamp},
* all other methods in this class can work with the extended timestamp range.
* For {@link getTimestamp}, because it is merely a wrapper of
* {@link mktime http://php.net/manual/en/function.mktime.php}, it may still
* be subject to the limit of timestamp range on certain platforms. Please refer
* to the PHP manual for more information.
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @package system.utils
* @since 1.0
*/
class CTimestamp
{
/**
* Gets day of week, 0 = Sunday,... 6=Saturday.
* Algorithm from PEAR::Date_Calc
* @param integer $year year
* @param integer $month month
* @param integer $day day
* @return integer day of week
*/
public static function getDayofWeek($year, $month, $day)
{
/*
Pope Gregory removed 10 days - October 5 to October 14 - from the year 1582 and
proclaimed that from that time onwards 3 days would be dropped from the calendar
every 400 years.
Thursday, October 4, 1582 (Julian) was followed immediately by Friday, October 15, 1582 (Gregorian).
*/
if ($year <= 1582)
{
if ($year < 1582 ||
($year == 1582 && ($month < 10 || ($month == 10 && $day < 15))))
{
$greg_correction = 3;
}
else
{
$greg_correction = 0;
}
}
else
{
$greg_correction = 0;
}
if($month > 2)
$month -= 2;
else
{
$month += 10;
$year--;
}
$day = floor((13 * $month - 1) / 5) +
$day + ($year % 100) +
floor(($year % 100) / 4) +
floor(($year / 100) / 4) - 2 *
floor($year / 100) + 77 + $greg_correction;
return $day - 7 * floor($day / 7);
}
/**
* Checks for leap year, returns true if it is. No 2-digit year check. Also
* handles julian calendar correctly.
* @param integer $year year to check
* @return boolean true if is leap year
*/
public static function isLeapYear($year)
{
$year = self::digitCheck($year);
if ($year % 4 != 0)
return false;
if ($year % 400 == 0)
return true;
// if gregorian calendar (>1582), century not-divisible by 400 is not leap
elseif ($year > 1582 && $year % 100 == 0 )
return false;
return true;
}
/**
* Fix 2-digit years. Works for any century.
* Assumes that if 2-digit is more than 30 years in future, then previous century.
* @param integer $y year
* @return integer change two digit year into multiple digits
*/
protected static function digitCheck($y)
{
if ($y < 100){
$yr = (integer) date("Y");
$century = (integer) ($yr /100);
if ($yr%100 > 50) {
$c1 = $century + 1;
$c0 = $century;
} else {
$c1 = $century;
$c0 = $century - 1;
}
$c1 *= 100;
// if 2-digit year is less than 30 years in future, set it to this century
// otherwise if more than 30 years in future, then we set 2-digit year to the prev century.
if (($y + $c1) < $yr+30) $y = $y + $c1;
else $y = $y + $c0*100;
}
return $y;
}
/**
* Returns 4-digit representation of the year.
* @param integer $y year
* @return integer 4-digit representation of the year
*/
public static function get4DigitYear($y)
{
return self::digitCheck($y);
}
/**
* @return integer get local time zone offset from GMT
*/
public static function getGMTDiff()
{
static $TZ;
if (isset($TZ)) return $TZ;
$TZ = mktime(0,0,0,1,2,1970) - gmmktime(0,0,0,1,2,1970);
return $TZ;
}
/**
* Returns the getdate() array.
* @param integer|boolean $d original date timestamp. False to use the current timestamp.
* @param boolean $fast false to compute the day of the week, default is true
* @param boolean $gmt true to calculate the GMT dates
* @return array an array with date info.
*/
public static function getDate($d=false,$fast=false,$gmt=false)
{
if($d===false)
$d=time();
if($gmt)
{
$tz = date_default_timezone_get();
date_default_timezone_set('GMT');
$result = getdate($d);
date_default_timezone_set($tz);
}
else
{
$result = getdate($d);
}
return $result;
}
/**
* Checks to see if the year, month, day are valid combination.
* @param integer $y year
* @param integer $m month
* @param integer $d day
* @return boolean true if valid date, semantic check only.
*/
public static function isValidDate($y,$m,$d)
{
return checkdate($m, $d, $y);
}
/**
* Checks to see if the hour, minute and second are valid.
* @param integer $h hour
* @param integer $m minute
* @param integer $s second
* @param boolean $hs24 whether the hours should be 0 through 23 (default) or 1 through 12.
* @return boolean true if valid date, semantic check only.
*/
public static function isValidTime($h,$m,$s,$hs24=true)
{
if($hs24 && ($h < 0 || $h > 23) || !$hs24 && ($h < 1 || $h > 12)) return false;
if($m > 59 || $m < 0) return false;
if($s > 59 || $s < 0) return false;
return true;
}
/**
* Formats a timestamp to a date string.
* @param string $fmt format pattern
* @param integer|boolean $d timestamp
* @param boolean $is_gmt whether this is a GMT timestamp
* @return string formatted date based on timestamp $d
*/
public static function formatDate($fmt,$d=false,$is_gmt=false)
{
if ($d === false)
return ($is_gmt)? @gmdate($fmt): @date($fmt);
// check if number in 32-bit signed range
if ((abs($d) <= 0x7FFFFFFF))
{
// if windows, must be +ve integer
if ($d >= 0)
return ($is_gmt)? @gmdate($fmt,$d): @date($fmt,$d);
}
$_day_power = 86400;
$arr = self::getDate($d,true,$is_gmt);
$year = $arr['year'];
$month = $arr['mon'];
$day = $arr['mday'];
$hour = $arr['hours'];
$min = $arr['minutes'];
$secs = $arr['seconds'];
$max = strlen($fmt);
$dates = '';
/*
at this point, we have the following integer vars to manipulate:
$year, $month, $day, $hour, $min, $secs
*/
for ($i=0; $i < $max; $i++)
{
switch($fmt[$i])
{
case 'T': $dates .= date('T');break;
// YEAR
case 'L': $dates .= $arr['leap'] ? '1' : '0'; break;
case 'r': // 2000年12月21日 16:01:07 +0200
// 4.3.11 uses '04 Jun 2004'
// 4.3.8 uses ' 4 Jun 2004'
$dates .= gmdate('D',$_day_power*(3+self::getDayOfWeek($year,$month,$day))).', '
. ($day<10?'0'.$day:$day) . ' '.date('M',mktime(0,0,0,$month,2,1971)).' '.$year.' ';
if ($hour < 10) $dates .= '0'.$hour; else $dates .= $hour;
if ($min < 10) $dates .= ':0'.$min; else $dates .= ':'.$min;
if ($secs < 10) $dates .= ':0'.$secs; else $dates .= ':'.$secs;
$gmt = self::getGMTDiff();
$dates .= sprintf(' %s%04d',($gmt<=0)?'+':'-',abs($gmt)/36);
break;
case 'Y': $dates .= $year; break;
case 'y': $dates .= substr($year,strlen($year)-2,2); break;
// MONTH
case 'm': if ($month<10) $dates .= '0'.$month; else $dates .= $month; break;
case 'Q': $dates .= ($month+3)>>2; break;
case 'n': $dates .= $month; break;
case 'M': $dates .= date('M',mktime(0,0,0,$month,2,1971)); break;
case 'F': $dates .= date('F',mktime(0,0,0,$month,2,1971)); break;
// DAY
case 't': $dates .= $arr['ndays']; break;
case 'z': $dates .= $arr['yday']; break;
case 'w': $dates .= self::getDayOfWeek($year,$month,$day); break;
case 'l': $dates .= gmdate('l',$_day_power*(3+self::getDayOfWeek($year,$month,$day))); break;
case 'D': $dates .= gmdate('D',$_day_power*(3+self::getDayOfWeek($year,$month,$day))); break;
case 'j': $dates .= $day; break;
case 'd': if ($day<10) $dates .= '0'.$day; else $dates .= $day; break;
case 'S':
$d10 = $day % 10;
if ($d10 == 1) $dates .= 'st';
elseif ($d10 == 2 && $day != 12) $dates .= 'nd';
elseif ($d10 == 3) $dates .= 'rd';
else $dates .= 'th';
break;
// HOUR
case 'Z':
$dates .= ($is_gmt) ? 0 : -self::getGMTDiff(); break;
case 'O':
$gmt = ($is_gmt) ? 0 : self::getGMTDiff();
$dates .= sprintf('%s%04d',($gmt<=0)?'+':'-',abs($gmt)/36);
break;
case 'H':
if ($hour < 10) $dates .= '0'.$hour;
else $dates .= $hour;
break;
case 'h':
if ($hour > 12) $hh = $hour - 12;
else {
if ($hour == 0) $hh = '12';
else $hh = $hour;
}
if ($hh < 10) $dates .= '0'.$hh;
else $dates .= $hh;
break;
case 'G':
$dates .= $hour;
break;
case 'g':
if ($hour > 12) $hh = $hour - 12;
else {
if ($hour == 0) $hh = '12';
else $hh = $hour;
}
$dates .= $hh;
break;
// MINUTES
case 'i': if ($min < 10) $dates .= '0'.$min; else $dates .= $min; break;
// SECONDS
case 'U': $dates .= $d; break;
case 's': if ($secs < 10) $dates .= '0'.$secs; else $dates .= $secs; break;
// AM/PM
// Note 00:00 to 11:59 is AM, while 12:00 to 23:59 is PM
case 'a':
if ($hour>=12) $dates .= 'pm';
else $dates .= 'am';
break;
case 'A':
if ($hour>=12) $dates .= 'PM';
else $dates .= 'AM';
break;
default:
$dates .= $fmt[$i]; break;
// ESCAPE
case "\\":
$i++;
if ($i < $max) $dates .= $fmt[$i];
break;
}
}
return $dates;
}
/**
* Generates a timestamp.
* This is the same as the PHP function {@link mktime http://php.net/manual/en/function.mktime.php}.
* @param integer $hr hour
* @param integer $min minute
* @param integer $sec second
* @param integer|boolean $mon month
* @param integer|boolean $day day
* @param integer|boolean $year year
* @param boolean $is_gmt whether this is GMT time. If true, gmmktime() will be used.
* @return integer|float a timestamp given a local time.
*/
public static function getTimestamp($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_gmt=false)
{
if ($mon === false)
return $is_gmt? @gmmktime($hr,$min,$sec): @mktime($hr,$min,$sec);
return $is_gmt ? @gmmktime($hr,$min,$sec,$mon,$day,$year) : @mktime($hr,$min,$sec,$mon,$day,$year);
}
}
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

基于Yii和bootstrap的开源OA/协同办公平台,连接全平台覆盖的酷办公客户端(Win,IOS,Android,Mac,Linux),支撑您的企业管理二次开发--作为国内首家开源OA,有的不只是颜值
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/case-code/IBOS.git
git@gitee.com:case-code/IBOS.git
case-code
IBOS
IBOS
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /