2016-10-13 00:16:48 点击量:4 标签: 收藏本文
[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);
- }
- }
- }
我们是一家提供综合软件外包与弱电工程服务的技术公司。
业务涵盖定制软件、管理系统、网站、小程序、APP、系统集成、网络布线、监控安防、门禁、机房建设及长期技术维护。
公司地址:湖北省宜昌市伍家岗区东站二路6号三峡(宜昌)大数据产业园海洋馆二楼A203室