日期字段更改为 2069 或 1970
我在 Flex 中有一个带有 editable="true" 的日期字段。 当我输入:20-1-69 并转到另一个字段时,它会变为 20-01-2069。但我不想让它变成2069。是否可以关闭这个自动更改的东西?
谢谢, JSMB
I have a datefield in flex with editable="true".
When I type: 20-1-69 and I go to another field, it changes into 20-01-2069. but I don't want it to change into 2069. Is it possible to turn off this automatically change thing?
Thanks,
JSMB
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
过去,当字节价格昂贵时,聪明的程序员使用两位数来存储日期。所以 60 被解释为 1960,一切都很好。
直到可怕的2000年临近,人们开始恐慌,因为计算机肯定会停止工作,我们都会死,或者至少被切断与互联网的联系,这可能更糟。
于是聪明的程序员被召唤来解决这个问题。
真正聪明的程序员将位数扩展到 4。但是自诩聪明的程序员却使用了滑动窗口。 70到99被解释为1970-1999年,0到69被解释为2000年到2069年。这当然解决了Y2K问题。但正如您所发现的,我们面临 2070 年的问题。
有趣的是,使用这个方案,像我这样的老家伙会在未来诞生。这让我们再次感觉年轻。所以他们很可能是故意这样做的。
In the past, when bytes where expensive, smart programmers used two digits to store the date. So a 60 was interpreted as an 1960 and all was wel.
Until the dreaded year 2000 was near, people started to panic, because computers would certainly stop to work and we would all die, or at least been cut from the Internet which is possibly worse.
So smart programmers were called to solve the problem.
Real smart programmers extended the number of digits to 4. But programmers that were self proclaimed smart, used the sliding window. 70 to 99 where interpreted as 1970-1999 and 0 to 69 was ineterpreted as 2000 to 2069. This of course solved the Y2K problem. But as you have found out, we have a 2070 problem.
The fun part is that, using this scheme, old guys like me are born in the future. Which makes us feel young again. So they probably did this on purpose.
您需要决定两位数日期在 1900 到 2000 之间的截止位置,然后对输入执行一些魔法。
示例:截止日期是 1940 年
(伪代码)
这将为您提供从 1941 年到 2040 年的年份。
You need to decide where you want the two-digit date to cut off between 1900 and 2000, and then perform some magic on the input.
Example: Cutoff is the year 1940
(pseudocode)
This will give you years from 1941 to 2040.
使用 DateValidator 强制使用 4 位数年份?如果您要输入旧日期,那么无论您拥有什么 SDK,这几乎都是一个要求。即使您想出了某种方法来实现这一点,一些用户也会感到困惑。
Use a DateValidator to enforce a 4 digit year? If you're going to be entering in old dates, this is pretty much a requirement no matter what SDK you have. Even if you work out some way to make this work, some user will come along and get confused.