English Japanese Kawa.netxp [JSAN] Date.W3CDTF - JavaScript Date object's W3CDTF extension

Date.W3CDTF class understands the W3CDTF date/time format, an ISO 8601 profile, defined by W3C. This date/time format is the native date format of RSS 1.0. It can be used to parse these formats in order to create the appropriate objects.
This is my first library to be contributed to JSAN.

Date.W3CDTF class supports two types of formats below:

2005-04-23T17:20:00+09:00 (with timezone)
2005-04-23T17:20:00Z     (without timezone)

Download

Get this library from JSAN or links following:

Archive: Date.W3CDTF-0.04.tar.gz TARGZ
.js source code only: lib/Date/W3CDTF.js JavaScript
Document: README README

This library is tested on IE 7, Firefox 1.5.0, Opera 8.53, Safari 2.0.3 and OmniWeb 5.1.3.

Usage

Date.W3CDTF class adds two methods for JavaScript's natvie Date class.
getW3CDTF() method is used to get a W3CDTF formated string from a Date object.
Its timezone is depend on your PC's system clock's configuration.
setW3CDTF() method is used to set date/time by a W3CDTF formated string.
Any other methods provided by natvie Date class are still available.

Static loading by <script> element

Static loading by <script> element. DEMO

<html>
<head>
<script src="lib/Date/W3CDTF.js"></script>
</head>
<body>
<script><!--
    var dd = new Date.W3CDTF();         // now
    document.write( "getW3CDTF: "+ dd.getW3CDTF() +"<br/>\n" );

    dd.setW3CDTF( "2005-04-23T17:20:00+09:00" );
    document.write( "toLocaleString: "+ dd.toLocaleString() +"<br/>\n" );
// --></script>
</body>
</html>

Dynamic Loading by JSAN.use() method

Dynamic Loading by JSAN.use() method. DEMO

<html>
<head>
<script src="tests/lib/JSAN.js"></script>
</head>
<body>
<script><!--

    JSAN.addRepository("lib");
    JSAN.errorLevel = "die";
    JSAN.use( 'Date.W3CDTF' );

    var dd = new Date.W3CDTF();         // now
    document.write( "getW3CDTF: "+ dd.getW3CDTF() +"<br/>\n" );

    dd.setW3CDTF( "2005-04-23T17:20:00+09:00" );
    document.write( "toLocaleString: "+ dd.toLocaleString() +"<br/>\n" );

// --></script>
</body>
</html>

Comments by AjaxCom

Links

Trackbacks by AjaxTB

Trackback URL:http://www.kawa.net/service/tb/ajaxtb.cgi/works/js/date/w3cdtf-e.html

Kawa.netxp © Copyright 2006 Yusuke Kawasaki