什么是使用Flex计算时代的最好方法? [英] What is the best way to calculate Age using Flex?
问题描述
什么是计算时代使用Flex的最佳方法是什么?
我发现了在<一个答案href="http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=08_Dates_and_times_164_2.html"相对=nofollow>这个页面的评论部分的底部(也就是现在的脱机)。
jpwrunyan说,2007年4月30号在10:10 PM:
顺便说一句,这里是如何计算年(只)从出生日期年龄,而无需考虑闰年:
通过将小幅盘整通过细威麟,在code读
私有函数getYearsOld(出生日期:日期):UINT {
VAR现在:日期=新的日期();
VAR yearsOld:UINT =号(now.fullYear) - 数字(dob.fullYear);
如果(dob.month&GT; now.month ||(dob.month == now.month和放大器;&安培; dob.date&GT; 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.
这篇关于什么是使用Flex计算时代的最好方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!