ENGLISH 意见建议 网站地图 网站帮助
广泛智力汇聚   高效成果传播   先进机制培育
联盟首页  |  协同开发  |  开放源码库  |  安全告警  |  开源导航  |  文档中心  |  服务支持  |  共创论坛  |  关于联盟


注册会员 网站帮助
    您的位置 »
    今天是: 2010年11月22日    
项目搜索

完全匹配   
开源软件
软件分类表
新发布软件
其它网站镜像
代码片断
协同开发
文档
论坛
寻求协助
热点项目
站点状态
编译工厂

联系我们
关于联盟

代码片段库:
查看代码片段

浏览 | 提交新的代码片段 | 创建代码包

英文的时间显示

类型:
Full Script
类别:
HTML Manipulation
许可证:
GNU General Public License
语言:
JavaScript
 
描述:
用标准的英文显示当前时间,还是蛮有新意的!

该代码片段的版本系列:

片段ID 下载版本 提交时间 提交人 删除
46911.02003-10-14 15:04cbd001

点击"下载版本"来下载该代码片段.


最新版本的代码片段: 1.0


脚本说明:
把如下代码加入<body>区域中
<script LANGUAGE="JavaScript">
<!-- Begin
function number(x) {
if (x==1) return "one"; if (x==2) return "two"; if (x==3) return "three";
if (x==4) return "four"; if (x==5) return "five"; if (x==6) return "six";
if (x==7) return "seven"; if (x==8) return "eight"; if (x==9) return "nine";
if (x==10) return "ten"; if (x==11) return "eleven"; if (x==12) return "twelve";
return x; //default
}
function ishtime(h,m) {
h = number(h)
if (m<=3 || m>57) return h+" o'clock";
if (m<=7)  return "five past "+h;
if (m<=12) return "ten past "+h;
if (m<=17) return "quarter past "+h;
if (m<=23) return "twenty past "+h;
if (m<=28) return "twenty-five past "+h;
if (m<=33) return "half past "+h;
if (m<=38) return "twenty-five to "+h;
if (m<=43) return "twenty to "+h;
if (m<=48) return "quarter to "+h;
if (m<=53) return "ten to "+h;
if (m<=58) return "five to "+h;
return "h:m"; // never reached?
}
function daytime(h) {
if (!h || h>21) return " at night"
if (h<12) return " in the morning";
if (h<=17) return " in the afternoon";
return " in the evening"; // default
}
function ish(h,m) {
if (!h && !m) { // if no time supplied, use the system time
time = new Date()
h = time.getHours()
m = time.getMinutes()
}
z = daytime(h);
h = h % 12 // fix to 12 hour clock
if (m>57 && time.getSeconds()>30) m++; // round seconds
if (m>60) m=0 // round up minutes
if (m>33) h++ // round up hours
if (h>12)  h = 1 // the clock turns round..
if (h==0) h = 12
return "It's now about "+ishtime(h,m)+z+"."
}
// End -->
</script>
<script language="JavaScript">
<!--HIDE FROM OLD BROWSERS--
document.writeln(ish().fontcolor("black"),"<P>")
<!--DONE-->
</script>

		

提交新版本

如果您修改了一个代码片段并且觉得很应该让别人共享,您可以把这作为这个代码片段的最新版本提交上来.


联盟团体会员
合作伙伴
© 共创软件联盟 版权所有
联盟服务条款 | 联盟隐私权规则 | 联系我们
电话: (8610)68313388-5949 | 传真: (8610)88377936
京ICP备05056057号