随笔-313  评论-12138  文章-1  trackbacks-256

Microsoft AJAX Library Cheat Sheet(2): Boolean和Date类型的扩展

 

本文为翻译,英文原版的Cheat Sheet(PDF版本)在此下载:http://aspnetresources.com/downloads/ms_ajax_library_cheat_sheets1.zip

原作版权声明:

Copyright (c) 2004-2006, Milan Negovan
http://www.AspNetResources.com
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 

注:标注有[S]的为静态方法,无须实例化对象即可使用。

 

[S] Boolean.parse (value )

从字符串表示的布尔值解析成相应的Boolean类型。value参数必须为“true”或“false”二者之一,不区分大小写,且可以包含空格。

var b = Boolean.parse("true");

 

Date.format (format)

格式化字符串(区域设定无关)。

var d = new Date();
Sys.Debug.trace (d.format("dddd, dd MMMM yyyy HH:mm:ss"));

 

Date.localeFormat (format)

格式化字符串(区域设定相关)。使用Sys.CultureInfo.CurrentCulture得到区域属性。

var d = new Date();
Sys.Debug.trace (d.localeFormat("dddd, dd MMMM yyyy HH:mm:ss"));

 

[S] Date.parseLocale (value, formats)

从字符串表示的本地时间日期解析成相应的Date类型。使用Sys.CultureInfo.CurrentCulture得到区域属性。

Sys.Debug.trace (Date.parseLocale ("4/10/2001", "yyyy-MM-dd",
"MM/dd/yyyy"));
// Date.parseLocale will skip the first format here as invalid and use
// the second one. If it does not find an appropriate format,
// the function throws an exception.

 

[S] Date.parseInvariant (value, formats)

从字符串表示的区域无关时间日期解析成相应的Date类型。

Sys.Debug.trace (Date.parseInvariant ("4/10/2001", "yyyy-MM-dd",
"MM/dd/yyyy"));
// Date.parseInvariant will skip the first format here as invalid and use
// the second one. If it does not find an appropriate format,
// the function throws an exception.

 

支持的格式

 

  1. d: 缩写日期(e.g.: 02/17/2007):
  2. D: 完整日期(e.g: Saturday, 17 February 2007)
  3. t: 缩写时间(e.g.: 22:10)
  4. T: 完整时间(e.g.: 22:10:30)
  5. F: 完整时间日期(e.g.: Saturday, 17 February 2007 22:10:30)
  6. m (or M): 月和日(e.g.: February 17)
  7. s: 可排序的时间日期(e.g.: 2007-02-17T22:10:30)
  8. y (or Y): 年和月(e.g.: 2007 February)
posted on 2007-02-04 17:00 Dflying Chen 阅读(2606) 评论(5) 编辑 收藏

评论:
#1楼 2007-05-09 08:18 | fdf[未注册用户]
[url=http://yongnia.googlepages.com/0.htm]翻版李嘉欣[/url]
[url=http://yongnia.googlepages.com/1.htm]原始夫妻生活[/url]
[url=http://yongnia.googlepages.com/2.htm]明星家保姆事件[/url]
[url=http://yongnia.googlepages.com/3.htm]十大打工皇帝[/url]
[url=http://yongnia.googlepages.com/4.htm]城管放假后的[/url]
[url=http://yongnia.googlepages.com/5.htm]抛腹产全过程[/url]
[url=http://yongnia.googlepages.com/6.htm]女星的今朝归宿[/url]
[url=http://yongnia.googlepages.com/7.htm]无线前高层自杀[/url]
[url=http://yongnia.googlepages.com/8.htm]中国军方神秘的七大[/url]
[url=http://yongnia.googlepages.com/9.htm]足坛悍夫娇妻[/url]
[url=http://yongnia.googlepages.com/10.htm]刘烨外籍女友[/url]
[url=http://yongnia.googlepages.com/11.htm]高清晰美女[/url]
[url=http://yongnia.googlepages.com/12.htm]虐猫虐鸭虐狗[/url]
[url=http://yongnia.googlepages.com/13.htm]吃剩饭族[/url]
[url=http://yongnia.googlepages.com/14.htm]嫁接人体[/url]
[url=http://yongnia.googlepages.com/15.htm]婚博会[/url]
[url=http://yongnia.googlepages.com/16.htm]艺人涉毒[/url]
[url=http://yongnia.googlepages.com/17.htm]第一美女[/url]
[url=http://yongnia.googlepages.com/18.htm]中国泳装趋势[/url]
[url=http://yongnia.googlepages.com/19.htm]倒霉明星[/url]
[url=http://yongnia.googlepages.com/20.htm]非常吻感[/url]

 回复 引用   
#2楼 2007-08-06 16:07 | TSENG      
在客戶端如何用Date.format (format),需要引用那些文件?


 回复 引用 查看   
#3楼[楼主] 2007-08-23 18:51 | Dflying Chen      
@TSENG
需要MicrosoftAjax.js

 回复 引用 查看   
除非特别声明,本站内所有资源,包括但不限于文章,代码,图片等,均应用于Dflying版权说明
关于ASP.NET AJAX,您可以:
直接阅读ASP.NET AJAX文章分类
Atlas文章打包下载(截至4/28/2006)
加入ASP.NET AJAX学习团队
询问关于ASP.NET AJAX的问题
加入ASP.NET AJAX讨论群
阅读愚作《ASP.NET AJAX程序设计》
点击阅读
点击阅读


关于Windows Vista,您可以:
加入Windows Vista开发团队!
昵称:Dflying Chen
园龄:5年10个月
粉丝:127
关注:0

搜索

 
 

最新随笔

随笔分类(352)

随笔档案(313)

Blog Roll

Dflying的其他Blog

Online Chat

统计信息

积分与排名

  • 积分 - 2442908
  • 排名 - 7

最新评论

阅读排行榜

评论排行榜