• AS3日期工具


     1 package com.evian.utils
    2 {
    3 public class DateUtil
    4 {
    5 public static const MINUTE_IN_MILLISECONDS : Number = 60 * 1000;
    6 public static const HOUR_IN_MILLISECONDS : Number = 60 * 60 * 1000;
    7 public static const DAY_IN_MILLISECONDS : Number = 24 * 60 * 60 * 1000;
    8 public static const WEEK_IN_MILLISECONDS : Number = 7 * 24 * 60 * 60 * 1000;
    9 public static const MONTH_IN_MILLISECONDS : Number = 30 * 24 * 60 * 60 * 1000;
    10 public static const YEAR_IN_MILLISECONDS : Number = 12 * 30 * 24 * 60 * 60 * 1000;
    11 public static const CENTURY_IN_MILLISECONDS : Number = 100 * 12 * 30 * 24 * 60 * 60 * 1000;
    12 public static const MILLENIUM_IN_MILLISECONDS : Number = 1000 * 100 * 12 * 30 * 24 * 60 * 60 * 1000;
    13
    14 public static function clearTime( date : Date ) : Date
    15 {
    16 date.date=1;
    17 date.hours = 0;
    18 date.minutes = 0;
    19 date.seconds = 0;
    20 date.milliseconds = 0;
    21
    22 return date;
    23 }
    24
    25 public static function copyDate( date : Date ) : Date
    26 {
    27 return new Date( date.getTime() );
    28 }
    29
    30 public static function setTime( date : Date, time : Number ) : Date
    31 {
    32 date.date = Math.ceil(time / (1000 * 60 * 60 *24));
    33 date.hours = Math.floor(( time / (1000 * 60 * 60)) % 24);
    34 date.minutes = Math.floor(( time / (1000 * 60)) % 60);
    35 date.seconds = Math.floor(( time / 1000) % 60);
    36 date.milliseconds = Math.floor( time % 1000);
    37
    38 return date;
    39 }
    40
    41 public static function addTime( date : Date, time : Number ) : Date
    42 {
    43 date.milliseconds += time;
    44
    45 return date;
    46 }
    47 /**
    48 * format to 00:00:00
    49 */
    50 public static function formatTimeString(hours:int,minutes:int,seconds:int):String
    51 {
    52 var h:String="";
    53 var m:String="";
    54 var s:String="";
    55
    56 h=hours>9?hours.toString():"0"+hours.toString();
    57 m=minutes>9?minutes.toString():"0"+minutes.toString();
    58 s=seconds>9?seconds.toString():"0"+seconds.toString();
    59
    60 return h+":"+m+":"+s;
    61 }
    62 /**
    63 * format to 00:00
    64 */
    65 public static function formatTimeToHour(hours:int,minutes:int,seconds:int):String
    66 {
    67
    68 var m:String="";
    69 var s:String="";
    70
    71 minutes+=hours*60;
    72 m=minutes>9?minutes.toString():"0"+minutes.toString();
    73 s=seconds>9?seconds.toString():"0"+seconds.toString();
    74
    75 return m+":"+s;
    76 }
    77 /**
    78 * @param seconds 秒
    79 * format to 00:00:00
    80 */
    81 public static function formatTimeToString2(seconds:int):String
    82 {
    83 var hour:int=seconds/3600;
    84 var minutes:int=seconds/60%60;
    85 var scecond:int=seconds-hour*3600-minutes*60;
    86
    87 return formatTimeString(hour,minutes,scecond);
    88
    89 }
    90 }
    91 }
  • 相关阅读:
    delphi中屏蔽浏览器控件右键菜单
    书目:一些
    数据库ADONETDataAdapter对象参考
    数据库ADONET排序、搜索和筛选
    易语言数据类型及其长度
    易语言数据类型的初始值
    数据库ADONET使用DataAdapter对象
    ADONET使用DataSet处理脱机数据
    数据库ADONETOleDbParameter对象参考
    在项目中添加新数据集
  • 原文地址:https://www.cnblogs.com/as3lib/p/2377735.html
Copyright © 2020-2023  润新知