[AS3]as3处理日期的工具源代码
[AS3]as3处理日期的工具源代码,as3处理日期,as3日期
[AS3]as3处理日期的工具源代码
- package com.evian.utils
- {
- public class DateUtil
- {
- public static const MINUTE_IN_MILLISECONDS : Number = 60 * 1000;
- public static const HOUR_IN_MILLISECONDS : Number = 60 * 60 * 1000;
- public static const DAY_IN_MILLISECONDS : Number = 24 * 60 * 60 * 1000;
- public static const WEEK_IN_MILLISECONDS : Number = 7 * 24 * 60 * 60 * 1000;
- public static const MONTH_IN_MILLISECONDS : Number = 30 * 24 * 60 * 60 * 1000;
- public static const YEAR_IN_MILLISECONDS : Number = 12 * 30 * 24 * 60 * 60 * 1000;
- public static const CENTURY_IN_MILLISECONDS : Number = 100 * 12 * 30 * 24 * 60 * 60 * 1000;
- public static const MILLENIUM_IN_MILLISECONDS : Number = 1000 * 100 * 12 * 30 * 24 * 60 * 60 * 1000;
- public static function clearTime( date : Date ) : Date
- {
- date.date=1;
- date.hours = 0;
- date.minutes = 0;
- date.seconds = 0;
- date.milliseconds = 0;
- return date;
- }
- public static function copyDate( date : Date ) : Date
- {
- return new Date( date.getTime() );
- }
- public static function setTime( date : Date, time : Number ) : Date
- {
- date.date = Math.ceil(time / (1000 * 60 * 60 *24));
- date.hours = Math.floor(( time / (1000 * 60 * 60)) % 24);
- date.minutes = Math.floor(( time / (1000 * 60)) % 60);
- date.seconds = Math.floor(( time / 1000) % 60);
- date.milliseconds = Math.floor( time % 1000);
- return date;
- }
- public static function addTime( date : Date, time : Number ) : Date
- {
- date.milliseconds += time;
- return date;
- }
- /**
- * format to 00:00:00
- */
- public static function formatTimeString(hours:int,minutes:int,seconds:int):String
- {
- var h:String="";
- var m:String="";
- var s:String="";
- h=hours>9?hours.toString():"0"+hours.toString();
- m=minutes>9?minutes.toString():"0"+minutes.toString();
- s=seconds>9?seconds.toString():"0"+seconds.toString();
- return h+":"+m+":"+s;
- }
- /**
- * format to 00:00
- */
- public static function formatTimeToHour(hours:int,minutes:int,seconds:int):String
- {
- var m:String="";
- var s:String="";
- minutes+=hours*60;
- m=minutes>9?minutes.toString():"0"+minutes.toString();
- s=seconds>9?seconds.toString():"0"+seconds.toString();
- return m+":"+s;
- }
- /**
- * @param seconds 秒
- * format to 00:00:00
- */
- public static function formatTimeToString2(seconds:int):String
- {
- var hour:int=seconds/3600;
- var minutes:int=seconds/60%60;
- var scecond:int=seconds-hour*3600-minutes*60;
- return formatTimeString(hour,minutes,scecond);
- }
- }
- }
热门文章推荐
- [HLS]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)
- [FMS]FMS流媒体服务器配置与使用相关的介绍
- [AS3]什么是M3U8,与HTML5的区别是什么
- AS2.0 让flash自适应全屏,并且不自动缩放
- [AS3]as3.0的sound类常用技巧整理
- [AS3]as3与ByteArray详解、ByteArray介绍、ByteArray用法
- 关于RTMP,RTMPT,RTMPS,RTMPE,RTMPTE协议的介绍
- [JS]分享浏览器弹出窗口不被拦截JS示例
请稍候...