由网友(心若冰凉人自亡)分享简介:什么是计算时代使用Flex的最佳方法是什么?解决方案 我发现了在这个页面的评论部分的底部(也就是现在的脱机)。 jpwrunyan说,2007年4月30号在10:10 PM: 顺便说一句,这里是如何计算年(只)从出生日期年龄,而无需考虑闰年:通过将小幅盘整通过细威麟,在code读 私有函数getYearsOld(出生...
什么是计算时代使用Flex的最佳方法是什么?
解决方案我发现了在这个页面的评论部分的底部(也就是现在的脱机)。
jpwrunyan说,2007年4月30号在10:10 PM:
顺便说一句,这里是如何计算年(只)从出生日期年龄,而无需考虑闰年:
通过将小幅盘整通过细威麟,在code读
私有函数getYearsOld(出生日期:日期):UINT {
VAR现在:日期=新的日期();
VAR yearsOld:UINT =号(now.fullYear) - 数字(dob.fullYear);
如果(dob.month> now.month ||(dob.month == now.month和放大器;&安培; dob.date> now.date))
{
yearsOld--;
}
返回yearsOld;
}
该处理大多数情况下,你需要计算年龄。
What is the best way to calculate Age using Flex?
解决方案I found an answer at the bottom of this page in comments section (which is now offline).
jpwrunyan said on Apr 30, 2007 at 10:10 PM :
By the way, here is how to calculate age in years (only) from DOB without needing to account for leap years:
With a slight correction by Fine-Wei Lin, the code reads
private function getYearsOld(dob:Date):uint {
var now:Date = new Date();
var yearsOld:uint = Number(now.fullYear) - Number(dob.fullYear);
if (dob.month > now.month || (dob.month == now.month && dob.date > now.date))
{
yearsOld--;
}
return yearsOld;
}
This handles most situations where you need to calculate age.
相关推荐
最新文章