Flex中计算某个月有多少天
2013-04-09 15:45
253 查看
/** *计算一个月中有多少天 * @author wangfeng * @date 2013年4月9日 15:47:58 */ private function dayCount(year:Number,month:Number):int { var result:int = 0; if(1==month || 3==month || 5==month|| 7==month || 8==month || 10==month || 12==month) { result = 31; }else if(4==month || 6==month || 9==month || 11==month) { result = 30; }else if(2==month) { if((year % 4 == 0 && year %100 !=0) || year % 400 == 0) { result = 29; }else { result = 28; } } return result; }
在Flex中创建一个日期是本月最后一天的Date对象:
private var endDate:Date = new Date(new Date().getFullYear(),new Date().getMonth(),dayCount(new Date().getFullYear(),new Date().getMonth()+1));
注意,getMonth()方法返回的是0到11.0代表1月。2代表2月。依次类推。因此,在参数传递的时候,要在getMonth()上加1
相关文章推荐
- Flex中计算某个月有多少天
- Oracle及Mysql中对当前时间的格式化及计算一个月有多少天
- 计算变量u中有多少个非0位
- 11.07,上课三程序,100内的素数,1000内的完数,输入一个数计算多少9
- 计算两个日期相隔多少年,多少月,多少天
- 每天一道LeetCode-----将数字集转成字母集,计算有多少种转换方式
- 计算 某一天据今天有多少天
- 有 1、 2、 3、 4 个数字, 能组成多少个互不相同且无重复数字的三位数? 计算并打印出这些数字
- php 如何计算两天之间相隔多少天
- java中如何计算一个字符串的byte长度(一个汉字多少字符)
- 计算N!末尾有多少个0
- CSS之深入理解 flex 布局以及计算
- java计算两个日期间过了多少天
- 002_005 Python 计算一个文件中有多少行即读取文件行数
- 【转】那我们是如何计算出客户地址多少米范围内有哪些门店呢
- 计算用户已经输入多少个字符
- PHP计算一年有多少周,每周开始日期和结束日期
- 计算当前月有多少天
- java的系统时间,怎么计算从现在到凌晨还剩下多少时间?
- 校oj1085 计算从左下到右上有多少不同走法