您的位置:首页 > 其它

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

2008-03-11 11:27 465 查看
本文为翻译,英文原版的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.


支持的格式

d: 缩写日期(e.g.: 02/17/2007):

D: 完整日期(e.g: Saturday, 17 February 2007)

t: 缩写时间(e.g.: 22:10)

T: 完整时间(e.g.: 22:10:30)

F: 完整时间日期(e.g.: Saturday, 17 February 2007 22:10:30)

m (or M): 月和日(e.g.: February 17)

s: 可排序的时间日期(e.g.: 2007-02-17T22:10:30)

y (or Y): 年和月(e.g.: 2007 February)

备注:本文引用自/article/4589291.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐