[cosmo-dev] Re: [commits-cosmo] (travis) [6985] Merge 6980 to trunk.

Travis Vachon travis at osafoundation.org
Thu May 15 13:56:22 PDT 2008


Er, this should have been "merge 6984 to trunk".

-Travis

On May 15, 2008, at 1:52 PM, svncheckin at osafoundation.org wrote:

> Revision
> 6985
> Author
> travis
> Date
> 2008-05-15 13:52:03 -0700 (Thu, 15 May 2008)
> Log Message
>
> Merge 6980 to trunk. Original commit message was:
> Bug 12076: timezone weirdness
> - Move tests datetime tests to new test structure + support code
> - Fix bug with date parsing code that was causing events with  
> timezones to be moved forward several hours every time they were saved
> - Cleanup in eim.js
> Modified Paths
>
> cosmo/trunk/cosmo-js/src/cosmo/datetime/serialize.js
> cosmo/trunk/cosmo-js/src/cosmo/env.js
> cosmo/trunk/cosmo-js/src/cosmo/service/translators/eim.js
> cosmo/trunk/cosmo-js/src/cosmo/testutils.js
> Added Paths
>
> cosmo/trunk/cosmo-js/src/cosmo/datetime/tests/
> cosmo/trunk/cosmo-js/src/cosmo/datetime/tests/date.js
> cosmo/trunk/cosmo-js/src/cosmo/datetime/tests/module.js
> cosmo/trunk/cosmo-js/src/cosmo/datetime/tests/runTests.html
> cosmo/trunk/cosmo-js/src/cosmo/datetime/tests/serialize.js
> cosmo/trunk/cosmo-js/src/cosmo/datetime/tests/timezone.js
> cosmo/trunk/cosmo-js/src/cosmo/tests/jum.js
> Removed Paths
>
> cosmo/trunk/cosmo/src/test/unit/js/cosmo/datetime/test_date.js
> cosmo/trunk/cosmo/src/test/unit/js/cosmo/datetime/test_serialize.js
> cosmo/trunk/cosmo/src/test/unit/js/cosmo/datetime/test_timezone.js
> Diff
>
> Deleted: cosmo/trunk/cosmo/src/test/unit/js/cosmo/datetime/ 
> test_date.js (6984 => 6985)
>
> --- cosmo/trunk/cosmo/src/test/unit/js/cosmo/datetime/test_date.js	 
> 2008-05-15 20:49:01 UTC (rev 6984)
> +++ cosmo/trunk/cosmo/src/test/unit/js/cosmo/datetime/test_date.js	 
> 2008-05-15 20:52:03 UTC (rev 6985)
> @@ -1,261 +0,0 @@
> -/*
> - * Copyright 2006 Open Source Applications Foundation
> - *
> - * Licensed under the Apache License, Version 2.0 (the "License");
> - * you may not use this file except in compliance with the License.
> - * You may obtain a copy of the License at
> - *
> - *     http://www.apache.org/licenses/LICENSE-2.0
> - *
> - * Unless required by applicable law or agreed to in writing,  
> software
> - * distributed under the License is distributed on an "AS IS" BASIS,
> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  
> implied.
> - * See the License for the specific language governing permissions  
> and
> - * limitations under the License.
> -*/
> -dojo.provide("cosmotest.datetime.test_date");
> -dojo.require("cosmo.datetime");
> -dojo.require("cosmo.datetime.Date");
> -dojo.require("cosmo.datetime.util");
> -dojo.require("cosmo.datetime.timezone.SimpleTimezoneRegistry");
> -dojo.require("cosmo.env");
> -
> -dojo.require("dojo.date.stamp");
> -
> -//Initialization.
> -//TODO - once Dojo implements setUp() and tearDown() move this code  
> there.
> -var registry = new  
> cosmo 
> .datetime.timezone.SimpleTimezoneRegistry(cosmo.env.getBaseUrl() + "/ 
> js/olson-tzdata/");
> -var D = cosmo.datetime.Date;
> -
> -registry.init(["northamerica"]);
> -cosmo.datetime.timezone.setTimezoneRegistry(registry);
> -
> -cosmotest.datetime.test_date = {
> -test_dateConstructor: function () {
> -    var dt = null;
> -    var dtComp = new Date(2006, 9, 23);
> -
> -    // Floating
> -    dt = new D(2006, 9, 23);
> -    jum.assertEquals(2006, dt.getFullYear());
> -    jum.assertEquals(9, dt.getMonth());
> -    jum.assertEquals(23, dt.getDate());
> -    jum.assertEquals(null, dt.tzId);
> -    jum.assertEquals(false, dt.utc);
> -    jum.assertEquals(dtComp.getTimezoneOffset(),  
> dt.getTimezoneOffset());
> -
> -    dt = new D(2006, 9, 23, 22, 12, 55, 6);
> -    jum.assertEquals(2006, dt.getFullYear());
> -    jum.assertEquals(9, dt.getMonth());
> -    jum.assertEquals(23, dt.getDate());
> -    jum.assertEquals(22, dt.getHours());
> -    jum.assertEquals(12, dt.getMinutes());
> -    jum.assertEquals(55, dt.getSeconds());
> -    jum.assertEquals(6, dt.getMilliseconds());
> -    jum.assertEquals(null, dt.tzId);
> -    jum.assertEquals(false, dt.utc);
> -    jum.assertEquals(dtComp.getTimezoneOffset(),  
> dt.getTimezoneOffset());
> -
> -    dt = new D('10/23/2006');
> -    jum.assertEquals(2006, dt.getFullYear());
> -    jum.assertEquals(9, dt.getMonth());
> -    jum.assertEquals(23, dt.getDate());
> -    jum.assertEquals(null, dt.tzId);
> -    jum.assertEquals(false, dt.utc);
> -    jum.assertEquals(dtComp.getTimezoneOffset(),  
> dt.getTimezoneOffset());
> -
> -    dt = new D(1161659575006);
> -    jum.assertEquals(2006, dt.getFullYear());
> -    jum.assertEquals(9, dt.getMonth());
> -    jum.assertEquals(23, dt.getDate());
> -    jum.assertEquals(null, dt.tzId);
> -    jum.assertEquals(false, dt.utc);
> -    jum.assertEquals(dtComp.getTimezoneOffset(),  
> dt.getTimezoneOffset());
> -
> -    // New York
> -    dt = new D(2006, 9, 23, 'America/New_York');
> -    jum.assertEquals(2006, dt.getFullYear());
> -    jum.assertEquals(9, dt.getMonth());
> -    jum.assertEquals(23, dt.getDate());
> -    jum.assertEquals('America/New_York', dt.tzId);
> -    jum.assertEquals(false, dt.utc);
> -    jum.assertEquals(240, dt.getTimezoneOffset());
> -
> -    dt = new D(2006, 9, 23, 22, 12, 55, 6, 'America/New_York');
> -    jum.assertEquals(2006, dt.getFullYear());
> -    jum.assertEquals(9, dt.getMonth());
> -    jum.assertEquals(23, dt.getDate());
> -    jum.assertEquals(22, dt.getHours());
> -    jum.assertEquals(12, dt.getMinutes());
> -    jum.assertEquals(55, dt.getSeconds());
> -    jum.assertEquals(6, dt.getMilliseconds());
> -    jum.assertEquals('America/New_York', dt.tzId);
> -    jum.assertEquals(false, dt.utc);
> -    jum.assertEquals(240, dt.getTimezoneOffset());
> -
> -    dt = new D('10/23/2006', 'America/New_York');
> -    jum.assertEquals(2006, dt.getFullYear());
> -    jum.assertEquals(9, dt.getMonth());
> -    jum.assertEquals(23, dt.getDate());
> -    jum.assertEquals('America/New_York', dt.tzId);
> -    jum.assertEquals(false, dt.utc);
> -    jum.assertEquals(240, dt.getTimezoneOffset());
> -
> -    // UTC, by timezone
> -    dt = new D(2006, 9, 23, 'Etc/UTC');
> -    jum.assertEquals(2006, dt.getFullYear());
> -    jum.assertEquals(9, dt.getMonth());
> -    jum.assertEquals(23, dt.getDate());
> -    jum.assertEquals('Etc/UTC', dt.tzId);
> -    jum.assertEquals(true, dt.utc);
> -    jum.assertEquals(0, dt.getTimezoneOffset());
> -
> -    dt = new D(2006, 9, 23, 22, 12, 55, 6, 'Etc/UTC');
> -    jum.assertEquals(2006, dt.getFullYear());
> -    jum.assertEquals(9, dt.getMonth());
> -    jum.assertEquals(23, dt.getDate());
> -    jum.assertEquals(22, dt.getHours());
> -    jum.assertEquals(12, dt.getMinutes());
> -    jum.assertEquals(55, dt.getSeconds());
> -    jum.assertEquals(6, dt.getMilliseconds());
> -    jum.assertEquals('Etc/UTC', dt.tzId);
> -    jum.assertEquals(true, dt.utc);
> -    jum.assertEquals(0, dt.getTimezoneOffset());
> -
> -    dt = new D('10/23/2006', 'Etc/UTC');
> -    jum.assertEquals(2006, dt.getFullYear());
> -    jum.assertEquals(9, dt.getMonth());
> -    jum.assertEquals(23, dt.getDate());
> -    jum.assertEquals('Etc/UTC', dt.tzId);
> -    jum.assertEquals(true, dt.utc);
> -    jum.assertEquals(0, dt.getTimezoneOffset());
> -
> -    // UTC, by flag
> -    dt = new D(2006, 9, 23, null, true);
> -    jum.assertEquals(2006, dt.getFullYear());
> -    jum.assertEquals(9, dt.getMonth());
> -    jum.assertEquals(23, dt.getDate());
> -    jum.assertEquals(null, dt.tzId);
> -    jum.assertEquals(true, dt.utc);
> -    jum.assertEquals(0, dt.getTimezoneOffset());
> -
> -    dt = new D(2006, 9, 23, 22, 12, 55, 6, null, true);
> -    jum.assertEquals(2006, dt.getFullYear());
> -    jum.assertEquals(9, dt.getMonth());
> -    jum.assertEquals(23, dt.getDate());
> -    jum.assertEquals(22, dt.getHours());
> -    jum.assertEquals(12, dt.getMinutes());
> -    jum.assertEquals(55, dt.getSeconds());
> -    jum.assertEquals(6, dt.getMilliseconds());
> -    jum.assertEquals(null, dt.tzId);
> -    jum.assertEquals(true, dt.utc);
> -    jum.assertEquals(0, dt.getTimezoneOffset());
> -
> -    dt = new D('10/23/2006', null, true);
> -    jum.assertEquals(2006, dt.getFullYear());
> -    jum.assertEquals(9, dt.getMonth());
> -    jum.assertEquals(23, dt.getDate());
> -    jum.assertEquals(null, dt.tzId);
> -    jum.assertEquals(true, dt.utc);
> -    jum.assertEquals(0, dt.getTimezoneOffset());
> -},
> -
> -test_dateGetOffset: function () {
> -    var dt = null;
> -
> -    dt = new D(2006, 9, 29, 1, 59, 'America/Los_Angeles');
> -    jum.assertEquals(420, dt.getTimezoneOffset());
> -
> -    dt = new D(2006, 9, 29, 2, 0, 'America/Los_Angeles');
> -    jum.assertEquals(480, dt.getTimezoneOffset());
> -},
> -
> -test_dateSetters: function () {
> -    var dt = null;
> -
> -    dt = new D(2006, 9, 23, 22, 12, 55, 6);
> -    dt.setMilliseconds(2112);
> -    jum.assertEquals(57, dt.getSeconds());
> -    jum.assertEquals(112, dt.getMilliseconds());
> -
> -    dt = new D(2006, 9, 23, 22, 12, 55, 6);
> -    dt.setSeconds(124);
> -    jum.assertEquals(14, dt.getMinutes());
> -    jum.assertEquals(4, dt.getSeconds());
> -
> -    dt = new D(2006, 9, 23, 22, 12, 55, 6);
> -    dt.setMinutes(-20);
> -    jum.assertEquals(21, dt.getHours());
> -    jum.assertEquals(40, dt.getMinutes());
> -
> -    dt = new D(2006, 9, 23, 22, 12, 55, 6);
> -    dt.setHours(52);
> -    jum.assertEquals(25, dt.getDate());
> -    jum.assertEquals(4, dt.getHours());
> -
> -    dt = new D(2006, 9, 23, 22, 12, 55, 6);
> -    dt.setDate(35);
> -    jum.assertEquals(10, dt.getMonth());
> -    jum.assertEquals(4, dt.getDate());
> -
> -    // Leap year
> -    dt = new D(2004, 1, 28);
> -    dt.setDate(29);
> -    jum.assertEquals(1, dt.getMonth());
> -    jum.assertEquals(29, dt.getDate());
> -
> -    // Non-leap-year
> -    dt = new D(2005, 1, 28);
> -    dt.setDate(29);
> -    jum.assertEquals(2, dt.getMonth());
> -    jum.assertEquals(1, dt.getDate());
> -
> -    // Wraparound broken in Safari 2, see WebKit bug 4892
> -    // http://bugs.webkit.org/show_bug.cgi?id=489
> -    // Safari 2 == Safari/412 to Safari/419.3
> -    // http://developer.apple.com/internet/safari/uamatrix.html
> -    if (navigator.userAgent.indexOf('Safari/41') == -1) {
> -        dt = new D(2006, 9, 23, 22, 12, 55, 6);
> -        dt.setMonth(14);
> -        jum.assertEquals(2007, dt.getYear());
> -        jum.assertEquals(2, dt.getMonth());
> -
> -        // Date wraparoud -- Set month to Feb with date of 31st
> -        // should wrap date to March 3rd
> -        dt = new D(2006, 0, 31);
> -        dt.setMonth(1);
> -        jum.assertEquals(2, dt.getMonth());
> -        jum.assertEquals(3, dt.getDate());
> -    }
> -},
> -
> -test_dateUTCSetters: function () {
> -    var dt = null;
> -
> -    // UTC date
> -    dt = new D(2006, 9, 23, 22, 12, 55, 6, 'Etc/UTC');
> -    dt.setUTCHours(54);
> -    // Should all be the same -- zero offset
> -    jum.assertEquals(25, dt.getUTCDate());
> -    jum.assertEquals(25, dt.getDate());
> -    jum.assertEquals(6, dt.getUTCHours());
> -    jum.assertEquals(6, dt.getHours());
> -
> -    // Wraparound broken in Safari 2, see WebKit bug 4892
> -    // http://bugs.webkit.org/show_bug.cgi?id=489
> -    // Safari 2 == Safari/412 to Safari/419.3
> -    // http://developer.apple.com/internet/safari/uamatrix.html
> -    if (navigator.userAgent.indexOf('Safari/41') == -1) {
> -        dt = new D(2006, 9, 23, 22, 12, 55, 6, 'America/Chicago');
> -        dt.setUTCHours(54);
> -        // Should all be the same -- zero offset
> -        jum.assertEquals(25, dt.getUTCDate());
> -        jum.assertEquals(25, dt.getDate());
> -        jum.assertEquals(6, dt.getUTCHours());
> -        jum.assertEquals(11, dt.getHours());
> -    }
> -},
> -
> -
> -
> -}
> \ No newline at end of file
> Deleted: cosmo/trunk/cosmo/src/test/unit/js/cosmo/datetime/ 
> test_serialize.js (6984 => 6985)
>
> --- cosmo/trunk/cosmo/src/test/unit/js/cosmo/datetime/ 
> test_serialize.js	2008-05-15 20:49:01 UTC (rev 6984)
> +++ cosmo/trunk/cosmo/src/test/unit/js/cosmo/datetime/ 
> test_serialize.js	2008-05-15 20:52:03 UTC (rev 6985)
> @@ -1,150 +0,0 @@
> -/*
> - * Copyright 2006-2007 Open Source Applications Foundation
> - *
> - * Licensed under the Apache License, Version 2.0 (the "License");
> - * you may not use this file except in compliance with the License.
> - * You may obtain a copy of the License at
> - *
> - *     http://www.apache.org/licenses/LICENSE-2.0
> - *
> - * Unless required by applicable law or agreed to in writing,  
> software
> - * distributed under the License is distributed on an "AS IS" BASIS,
> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  
> implied.
> - * See the License for the specific language governing permissions  
> and
> - * limitations under the License.
> -*/
> -
> -dojo.provide("cosmotest.datetime.test_serialize");
> -
> -dojo.require("cosmo.datetime.serialize");
> -
> -cosmotest.datetime.test_serialize = {
> -
> -
> -    test_fromIso8601: function (){
> -
> -    },
> -
> -    test_fromIso8601Date: function (){
> -
> -    },
> -
> -    test_fromIso8601Time: function (){
> -
> -    },
> -
> -    test_fromRfc3339: function (){
> -
> -    },
> -
> -    test_addIso8601Duration: function (){
> -
> -    },
> -
> -    test_getIso8601Duration: function(){
> -
> -    },
> -
> -    test_durationHashToIso8601: function (){
> -        var d1 = {year: 1, month: 2, day: 3, hour: 4, minute: 5,  
> second: 6};
> -        var ds = cosmo.datetime.durationHashToIso8601(d1);
> -        jum.assertEquals("first duration hash wrong",  
> "P1Y2M3DT4H5M6S", ds);
> -
> -        var d2 = {year: 1, month: 2, day: 3};
> -        ds = cosmo.datetime.durationHashToIso8601(d2);
> -        jum.assertEquals("first duration hash wrong", "P1Y2M3D", ds);
> -
> -        var d3 = {hour: 4, minute: 5, second: 6};
> -        ds = cosmo.datetime.durationHashToIso8601(d3);
> -        jum.assertEquals("first duration hash wrong", "PT4H5M6S",  
> ds);
> -
> -    },
> -
> -    test_parseIso8601Duration: function(){
> -        var d1 = {year: 1, month: 2, day: 3, hour: 4, minute: 5,  
> second: 6};
> -        var d2 = cosmo.datetime.parseIso8601Duration(
> -          cosmo.datetime.durationHashToIso8601(d1)
> -          );
> -
> -        cosmotest.datetime.test_serialize.durationsEqual("1", d1,  
> d2);
> -
> -        // Make sure things are numbers
> -        jum.assertEquals(2, d2.year + 1);
> -
> -        d1 = {year: 1, month: 2, day: 3};
> -        d2 = cosmo.datetime.parseIso8601Duration(
> -          cosmo.datetime.durationHashToIso8601(d1)
> -          );
> -
> -        cosmotest.datetime.test_serialize.durationsEqual("2", d1,  
> d2);
> -
> -        d1 = {hour: 4, minute: 5, second: 6};
> -        d2 = cosmo.datetime.parseIso8601Duration(
> -          cosmo.datetime.durationHashToIso8601(d1)
> -          );
> -
> -        cosmotest.datetime.test_serialize.durationsEqual("3", d1,  
> d2);
> -
> -        d1 = {week:1};
> -        d2 = cosmo.datetime.parseIso8601Duration(
> -          cosmo.datetime.durationHashToIso8601(d1)
> -        );
> -
> -        cosmotest.datetime.test_serialize.durationsEqual("4", d1,  
> d2);
> -    },
> -
> -   test_dojoFromIso8601: function(){
> -       //we monkey-patched dojo.date.fromIso8601 to fix a bug that  
> occurs when
> -       //parsing dates near DST switchover time. But then we  
> switched over to dojo
> -       //1.0 which didn't have quite the same function, so we wrote  
> our own.
> -       //This verifies that this is no longer a problem.
> -       var string = "20071104T190000Z";
> -       var jsDate = cosmo.datetime.fromIso8601(string);
> -       //should be 19, but unpatched gives 20!
> -       jum.assertEquals("Should be 19", 19,jsDate.getUTCHours())
> -   },
> -
> -    test_parseIso8601: function(){
> -        var p = cosmo.datetime.util.dateParts;
> -
> -        var tests = [["20000101", 2000, 0, 1],
> -                     ["20000131", 2000, 0, 31],
> -                     ["20080229", 2008, 1, 29],
> -                     ["20000101T000000", 2000, 0, 1],
> -                     ["20000505T000000", 2000, 4, 5],
> -                     ["20000101T050505", 2000, 0, 1, 5, 5, 5],
> -                     ["20000101T050505", 2000, 0, 1, 5, 5, 5],
> -                     ["20080108T123045", 2008, 0, 8, 12, 30, 45]
> -                     ];
> -
> -        for (var i in tests){
> -            var test = tests[i];
> -            var dateParts = cosmo.datetime.parseIso8601(test[0]);
> -            jum.assertEquals(test[0] + " year", test[1],  
> dateParts[p.YEAR]);
> -            jum.assertEquals(test[0] + " month", test[2],  
> dateParts[p.MONTH]);
> -            jum.assertEquals(test[0] + " day", test[3],  
> dateParts[p.DAY]);
> -            jum.assertEquals(test[0] + " hour", test[4] || 0,  
> dateParts[p.HOUR]);
> -            jum.assertEquals(test[0] + " minute", test[5] || 0,  
> dateParts[p.MINUTE]);
> -            jum.assertEquals(test[0] + " second", test[6] || 0,  
> dateParts[p.SECOND]);
> -        }
> -    },
> -
> -    /* Makes sure properties specified in the expected match the  
> actual.
> -     * Also, makes sure properties not specified in the expected
> -     * will resolve to boolean false.
> -     */
> -    durationsEqual: function(id, d1, d2){
> -        if (d1.year) jum.assertEquals(id + ": year", d1.year,  
> d2.year);
> -        else jum.assertFalse(id + ": year", !!d2.year);
> -        if (d1.month) jum.assertEquals(id + ": month", d1.month,  
> d2.month);
> -        else jum.assertFalse(id + ": month", !!d2.month);
> -        if (d1.day) jum.assertEquals(id + ": day", d1.day, d2.day);
> -        else jum.assertFalse(id + ": day", !!d2.day);
> -        if (d1.hour) jum.assertEquals(id + ": hour", d1.hour,  
> d2.hour);
> -        else jum.assertFalse(id + ": hour", !!d2.hour);
> -        if (d1.minute) jum.assertEquals(id + ": minute", d1.minute,  
> d2.minute);
> -        else jum.assertFalse(id + ": minute", !!d2.minute);
> -        if (d1.second) jum.assertEquals(id + ": second", d1.second,  
> d2.second);
> -        else jum.assertFalse(id + ": second", !!d2.second);
> -    }
> -}
> Deleted: cosmo/trunk/cosmo/src/test/unit/js/cosmo/datetime/ 
> test_timezone.js (6984 => 6985)
>
> --- cosmo/trunk/cosmo/src/test/unit/js/cosmo/datetime/ 
> test_timezone.js	2008-05-15 20:49:01 UTC (rev 6984)
> +++ cosmo/trunk/cosmo/src/test/unit/js/cosmo/datetime/ 
> test_timezone.js	2008-05-15 20:52:03 UTC (rev 6985)
> @@ -1,320 +0,0 @@
> -/*
> - * Copyright 2006 Open Source Applications Foundation
> - *
> - * Licensed under the Apache License, Version 2.0 (the "License");
> - * you may not use this file except in compliance with the License.
> - * You may obtain a copy of the License at
> - *
> - *     http://www.apache.org/licenses/LICENSE-2.0
> - *
> - * Unless required by applicable law or agreed to in writing,  
> software
> - * distributed under the License is distributed on an "AS IS" BASIS,
> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  
> implied.
> - * See the License for the specific language governing permissions  
> and
> - * limitations under the License.
> -*/
> -
> -dojo.provide("cosmotest.datetime.test_timezone");
> -dojo.require("cosmo.datetime");
> -dojo.require("cosmo.datetime.Date");
> -dojo.require("cosmo.datetime.timezone");
> -dojo.require("cosmo.datetime.timezone.LazyCachingTimezoneRegistry");
> -//Initialization.
> -//TODO - once Dojo implements setUp() and tearDown() move this code  
> there.
> -
> -var registry = new  
> cosmo 
> .datetime 
> .timezone.LazyCachingTimezoneRegistry(cosmo.env.getBaseUrl() + "/js/ 
> olson-tzdata/");
> -
> -cosmo.datetime.timezone.setTimezoneRegistry(registry);
> -
> -cosmotest.datetime.test_timezone = {
> -    getNyTz: function (){
> -        var timezone = cosmo.datetime.timezone.getTimezone("America/ 
> New_York");
> -        return timezone;
> -    },
> -
> -    getUsRs: function (){
> -        var rs = cosmo.datetime.timezone.getRuleSet("US");
> -        return rs;
> -    },
> -
> -    test_getTimezone: function (){
> -        var timezone = cosmotest.datetime.test_timezone.getNyTz();
> -        jum.assertTrue(timezone != null);
> -    },
> -
> -    test_getDateField: function (){
> -        var getDateField = cosmo.datetime.timezone._getDateField;
> -        var cosmoDate = new cosmo.datetime.Date(2006, 11, 10, 12,  
> 33, 30);
> -        jum.assertEquals(2006, getDateField(cosmoDate, "year"));
> -        jum.assertEquals(11, getDateField(cosmoDate, "month"));
> -        jum.assertEquals(10, getDateField(cosmoDate, "date"));
> -        jum.assertEquals(12, getDateField(cosmoDate, "hours"));
> -        jum.assertEquals(33, getDateField(cosmoDate, "minutes"));
> -        jum.assertEquals(30, getDateField(cosmoDate, "seconds"));
> -
> -        var jsDate = new Date(2006, 11, 10, 12, 33, 30);
> -        jum.assertEquals(2006, getDateField(jsDate, "year"));
> -        jum.assertEquals(11, getDateField(jsDate, "month"));
> -        jum.assertEquals(10, getDateField(jsDate, "date"));
> -        jum.assertEquals(12, getDateField(jsDate, "hours"));
> -        jum.assertEquals(33, getDateField(jsDate, "minutes"));
> -        jum.assertEquals(30, getDateField(jsDate, "seconds"));
> -
> -        var fullHashDate = { year: 2006,
> -                             month: 11,
> -                             date: 10,
> -                             hours: 12,
> -                             minutes: 33,
> -                             seconds: 30};
> -
> -        jum.assertEquals(2006, getDateField(fullHashDate, "year"));
> -        jum.assertEquals(11, getDateField(fullHashDate, "month"));
> -        jum.assertEquals(10, getDateField(fullHashDate, "date"));
> -        jum.assertEquals(12, getDateField(fullHashDate, "hours"));
> -        jum.assertEquals(33, getDateField(fullHashDate, "minutes"));
> -        jum.assertEquals(30, getDateField(fullHashDate, "seconds"));
> -
> -        var sparseHashDate = { year: 2006,
> -                               month: 11 };
> -
> -        jum.assertEquals(2006, getDateField(sparseHashDate, "year"));
> -        jum.assertEquals(11, getDateField(sparseHashDate, "month"));
> -        jum.assertEquals(1, getDateField(sparseHashDate, "date"));
> -        jum.assertEquals(0, getDateField(sparseHashDate, "hours"));
> -        jum.assertEquals(0, getDateField(sparseHashDate, "minutes"));
> -        jum.assertEquals(0, getDateField(sparseHashDate, "seconds"));
> -    },
> -
> -    test_compareDates: function (){
> -        var compareDates = cosmo.datetime.timezone._compareDates;
> -        var jsDate1 = new Date(2006, 11, 10, 12, 33, 30);
> -        var jsDate2 = new Date(2007, 11, 10, 12, 33, 30);
> -        jum.assertTrue(compareDates(jsDate1, jsDate2) < 0);
> -
> -        jsDate1 = new Date(2006, 11, 10, 12, 33, 30);
> -        jsDate2 = new Date(2006, 11, 10, 12, 33, 30);
> -        jum.assertTrue(compareDates(jsDate1, jsDate2) == 0);
> -
> -        jsDate1 = new Date(2006, 11, 10, 12, 33, 31);
> -        jsDate2 = new Date(2006, 11, 10, 12, 33, 30);
> -        jum.assertTrue(compareDates(jsDate1, jsDate2)  > 0);
> -
> -        jsDate1 = new Date(2006, 11, 10, 13, 33, 31);
> -        jsDate2 = new Date(2006, 11, 10, 12, 33, 31);
> -        jum.assertTrue(compareDates(jsDate1, jsDate2)  > 0);
> -
> -        var sparseHashDate = { year: 2006,
> -                               month: 11 };
> -        jsDate2 = new Date(2006, 11, 1, 1, 1, 1, 1);
> -        jum.assertTrue(compareDates(sparseHashDate, jsDate2) < 0);
> -    },
> -
> -    test_getZoneItemForDate: function (){
> -        var tz = cosmotest.datetime.test_timezone.getNyTz();
> -        var date = new Date(2006, 1, 1);
> -        var zoneItem = tz._getZoneItemForDate(date);
> -        jum.assertEquals(null, zoneItem.untilDate);
> -
> -        date = new Date(1966, 11, 31);
> -        zoneItem = tz._getZoneItemForDate(date);
> -        jum.assertEquals(1967, zoneItem.untilDate.year);
> -
> -        date = new Date(1800, 1, 1);
> -        zoneItem = tz._getZoneItemForDate(date);
> -        jum.assertEquals(1883, zoneItem.untilDate.year);
> -
> -        date = new Date(1920, 1, 1);
> -        zoneItem = tz._getZoneItemForDate(date);
> -        jum.assertEquals(1942, zoneItem.untilDate.year);
> -        },
> -
> -        test_getRulesForYear:     function (){
> -        var rs = cosmotest.datetime.test_timezone.getUsRs();
> -        var rules = rs._getRulesForYear(1999);
> -        jum.assertEquals(2, rules.length);
> -        jum.assertEquals(1967, rules[0].startYear);
> -    },
> -
> -    test_DayGreateThanNForMonthAndYear: function (){
> -        var func =  
> cosmo.datetime.timezone._getDayGreaterThanNForMonthAndYear;
> -
> -        //"get me the date of the first thursday that is greater  
> than or equal to the 8th in November"
> -        var date = func(8, 4, 10, 2006);
> -        jum.assertEquals(9, date);
> -
> -        //"get me the date of the first wednesday that is greater  
> than or equal to the 8th in November"
> -        date = func(8, 3, 10, 2006);
> -        jum.assertEquals(8, date);
> -
> -        //"get me the date of the first tuesday that is greater  
> than or equal to the 8th in November"
> -        date = func(8, 2, 10, 2006);
> -        jum.assertEquals(14, date);
> -    },
> -
> -    test_DayLessThanNForMonthAndYear: function (){
> -        var func =  
> cosmo.datetime.timezone._getDayLessThanNForMonthAndYear;
> -
> -        //"get me the date of the last thursday that is less than  
> or equal to the 8th in November"
> -        var date = func(8,4,10,2006);
> -        jum.assertEquals(2, date);
> -
> -        //"get me the date of the last wednesday that is less than  
> or equal to the 8th in November"
> -        var date = func(8,3,10,2006);
> -        jum.assertEquals(8, date);
> -
> -        //"get me the date of the last tuesday that is less than or  
> equal to the 8th in November"
> -        var date = func(8,2,10,2006);
> -        jum.assertEquals(7, date);
> -    },
> -
> -    test_getStartDateForYear: function (){
> -      //to test:  
> cosmo.datetime.timezone.Rule.prototype._getStartDateForYear =  
> function(year)
> -      var rs = cosmotest.datetime.test_timezone.getUsRs();
> -      var sorter = function(a,b){return a.startMonth - b.startMonth};
> -
> -      var rules = rs._getRulesForYear(1967);
> -      rules.sort(sorter);
> -      var startDate = rules[0]._getStartDateForYear(2006);
> -
> -      //for sanity's sake, make sure it's APR
> -      jum.assertEquals(3, startDate.month);
> -
> -      //rule says Apr, lastSun - last sunday in april which is the  
> 30th
> -      jum.assertEquals(30, startDate.date);
> -
> -      rules = rs._getRulesForYear(1974);
> -      rules.sort(sorter);
> -      startDate = rules[0]._getStartDateForYear(1974);
> -
> -      //rule says "jan 6"
> -      jum.assertEquals(0, startDate.month);
> -      jum.assertEquals(6, startDate.date);
> -
> -      rules = rs._getRulesForYear(2007);
> -      rules.sort(sorter);
> -      startDate = rules[0]._getStartDateForYear(2007);
> -
> -      //rule sun>=8 - first sunday after or on the eighth which is  
> the 11th
> -      jum.assertEquals(2, startDate.month);
> -      jum.assertEquals(11, startDate.date);
> -    },
> -
> -    test_getOffsetInMinutes: function (){
> -    var timezone = cosmotest.datetime.test_timezone.getNyTz();
> -    var date;
> -    var offset;
> -
> -    date = new Date(2006, 1, 1);
> -    offset = timezone.getOffsetInMinutes(date);
> -    jum.assertEquals(-300, offset);
> -
> -    date = new Date(2006, 3, 1);
> -    offset = timezone.getOffsetInMinutes(date);
> -    jum.assertEquals(-300, offset);
> -
> -    date = new Date(2006, 3, 2, 1, 59, 69);
> -    offset = timezone.getOffsetInMinutes(date);
> -    jum.assertEquals(-300, offset);
> -
> -    date = new Date(2006, 3, 2, 3, 0, 0);
> -    offset = timezone.getOffsetInMinutes(date);
> -    jum.assertEquals(-240, offset);
> -    },
> -
> -    test_getRuleForDate: function(){
> -        //var tz =  
> cosmo.datetime.timezone._timezoneRegistry.getTimezone("America/ 
> Barbados");
> -        var date = new Date(2006, 1, 1);
> -        var ruleSet = cosmo.datetime.timezone.getRuleSet("Barb");
> -        var rule = ruleSet._getRuleForDate(date);
> -        jum.assertTrue(rule != null);
> -        jum.assertTrue(rule.startYear == 1980);
> -        jum.assertTrue(rule.letter == "S");
> -
> -    },
> -
> -    getPrefixes: function (){
> -    var files = ["northamerica", "africa", "antarctica", "asia",  
> "australasia", "europe", "pacificnew", "southamerica", "backward"];
> -    var prefixes = {};
> -
> -    function spit(file){
> -        var content =  
> dojo 
> .hostenv 
> .getText(cosmo.datetime.timezone._timezoneRegistry.timezoneFileRoot  
> + "/" + file);
> -        cosmo.datetime.timezone.parse(content,
> -            function(tz){
> -                var prefix = tz.tzId.split("\/")[0];
> -                var prefixRecord = prefixes[prefix];
> -                if (!prefixRecord){
> -                   prefixes[prefix] = {};
> -                   prefixes[prefix][file] = 1;
> -                } else {
> -                    if (!prefixRecord[file]){
> -                        prefixRecord[file] = 1;
> -                    } else {
> -                        prefixRecord[file] = prefixRecord[file] + 1;
> -                    }
> -                }
> -
> -            }, function(){}, function(){});
> -    }
> -
> -    for (var x = 0; x < files.length; x++){
> -        spit(files[x]);
> -    }
> -
> -    return prefixes;
> -},
> -
> -getPrefixToFileMap: function (){
> -
> -    function getFileNameWithMostTzids(record){
> -        var winner = 0;
> -        var winnerFile = "";
> -        for (var file in record){
> -            var num = record[file];
> -            if (num > winner){
> -                winner = num;
> -                winnerFile = file;
> -            }
> -        }
> -        return winnerFile;
> -    }
> -
> -    var prefixes = getPrefixes();
> -    var map = {};
> -    for (var prefix in prefixes){
> -        var record = prefixes[prefix];
> -        map[prefix] = getFileNameWithMostTzids(record);
> -    }
> -
> -    return map;
> -},
> -
> -printPrefixes: function (){
> -    var prefixes = getPrefixes();
> -    for (var prefix in prefixes){
> -        print("Prefix: '" + prefix + "'");
> -        var record = prefixes[prefix];
> -        for (var file in record){
> -            print("    '" + file + "': " + record[file]);
> -        }
> -    }
> -},
> -
> -getExceptionMap: function (){
> -   var prefixToFileMap = getPrefixToFileMap();
> -   var files = ["northamerica", "africa", "antarctica", "asia",  
> "australasia", "europe", "pacificnew", "southamerica", "backward"];
> -   var map = {};
> -
> -   for (var x = 0; x < files.length; x++){
> -       var file = files[x];
> -       var content =  
> dojo 
> .hostenv 
> .getText(cosmo.datetime.timezone._timezoneRegistry.timezoneFileRoot  
> + "/" + file);
> -       cosmo.datetime.timezone.parse(content, function(timezone){
> -           var prefix = timezone.tzId.split("\/")[0];
> -           if (prefixToFileMap[prefix] != file ){
> -              map[timezone.tzId] = file;
> -           }
> -       }, function(){}, function(){});
> -   }
> -
> -   return map;
> -}
> -}
> \ No newline at end of file
> Modified: cosmo/trunk/cosmo-js/src/cosmo/datetime/serialize.js (6984  
> => 6985)
>
> --- cosmo/trunk/cosmo-js/src/cosmo/datetime/serialize.js	2008-05-15  
> 20:49:01 UTC (rev 6984)
> +++ cosmo/trunk/cosmo-js/src/cosmo/datetime/serialize.js	2008-05-15  
> 20:52:03 UTC (rev 6985)
> @@ -15,7 +15,7 @@
>  */
>  dojo.provide("cosmo.datetime.serialize");
>
> -dojo.require("cosmo.datetime.util")
> +dojo.require("cosmo.datetime.util");
>  //for iso8601 parsing
>  cosmo.datetime._iso8601DateFormatString = "yyyyMMdd";
>  cosmo.datetime._iso8601TimeFormatString = "HHmmss";
> @@ -35,13 +35,17 @@
>      else if (formattedString.substring(formattedString.length -  
> 1).toLowerCase() == "z"){
>          date.utc = true;
>      }
> -    dojo.date.stamp._isoRegExp = /^(?:(\d{4})(?:(\d{2})(?: 
> (\d{2}))?)?)?(?:T(\d{2})(\d{2})(?:(\d{2})())?((?:[+-](\d{2})(\d{2}))| 
> Z)?)?$/
> -     
> date 
> .updateFromUTC 
> (dojo.date.stamp.fromISOString(formattedString).getTime());
> -    dojo.date.stamp._isoRegExp = null;
> +    var dateProps = cosmo.datetime.parseIso8601(formattedString);
> +    date.setYear(dateProps[ parts.YEAR]);
> +    date.setMonth(dateProps[parts.MONTH]);
> +    date.setDate(dateProps[parts.DAY]);
> +    date.setHours(dateProps[parts.HOUR]);
> +    date.setMinutes(dateProps[parts.MINUTE]);
> +    date.setSeconds(dateProps[parts.SECOND]);
>      return date;
>  };
>
> -//summary: parses a date or datetime and returns an object set with  
> the
> +//summary: parses a date or datetime and returns an object set with  
> the
>  //various date properties.
>  cosmo.datetime.parseIso8601 = function(str) {
>      var parts = cosmo.datetime.util.dateParts;
> @@ -53,7 +57,7 @@
>      o[parts.YEAR] = parseInt(str.substring(0,4), 10);
>      o[parts.MONTH] = parseInt(str.substring(4,6), 10) - 1;
>      o[parts.DAY] = parseInt(str.substring(6,8), 10);
> -
> +
>      if (hasTime){
>          o[parts.HOUR] = parseInt(str.substring(9,11), 10);
>          o[parts.MINUTE] = parseInt(str.substring(11,13), 10);
> @@ -67,7 +71,7 @@
>      return o;
>  }
>
> -cosmo.datetime.parseIso8601Duration =
> +cosmo.datetime.parseIso8601Duration =
>  function parseIso8601Duration(/*String*/duration){
>     var r = "^(-?)P(?:(?:([0-9\.]*)Y)?(?:([0-9\.]*)M)?(?: 
> ([0-9\.]*)D)?(?:T(?:([0-9\.]*)H)?(?:([0-9\.]*)M)?(?:([0-9\.]*)S)?)?) 
> (?:([0-9/.]*)W)?$"
>     var dateArray = duration.match(r).slice(1);
> @@ -85,8 +89,8 @@
>     return dateHash
>  }
>
> -cosmo.datetime.addIso8601Duration =
> -function addIso8601Duration(/*cosmo.datetime.Date*/date,
> +cosmo.datetime.addIso8601Duration =
> +function addIso8601Duration(/*cosmo.datetime.Date*/date,
>                              /*String or Object*/duration){
>      var dHash;
>      if (typeof(duration) == "string"){
> @@ -94,7 +98,7 @@
>      } else {
>          dHash = duration;
>      }
> -
> +
>      with (cosmo.datetime.util.dateParts){
>          if (dHash.year) date.add(YEAR, dHash.year);
>          if (dHash.month) date.add(MONTH, dHash.month);
> @@ -115,7 +119,7 @@
>  }
>
>  cosmo.datetime.getDuration = function getDuration(dt1, dt2){
> -
> +
>      var dur = {}
>      with (cosmo.datetime.durationsInSeconds){
>          var multiplier = 1;
> @@ -140,7 +144,7 @@
>     return dur;
>  }
>
> -cosmo.datetime.durationHashToIso8601 =
> +cosmo.datetime.durationHashToIso8601 =
>  function durationHashToIso8601(/*Object*/dur){
>      var ret =  "P";
>      if (dur.year) ret += dur.year + "Y";
> Added: cosmo/trunk/cosmo-js/src/cosmo/datetime/tests/date.js (6984  
> => 6985)
>
> --- cosmo/trunk/cosmo-js/src/cosmo/datetime/tests/date.js	2008-05-15  
> 20:49:01 UTC (rev 6984)
> +++ cosmo/trunk/cosmo-js/src/cosmo/datetime/tests/date.js	2008-05-15  
> 20:52:03 UTC (rev 6985)
> @@ -0,0 +1,261 @@
> +/*
> + * Copyright 2006 Open Source Applications Foundation
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,  
> software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  
> implied.
> + * See the License for the specific language governing permissions  
> and
> + * limitations under the License.
> + */
> +dojo.provide("cosmo.datetime.tests.date");
> +dojo.require("cosmo.tests.jum");
> +dojo.require("cosmo.datetime");
> +dojo.require("cosmo.datetime.Date");
> +dojo.require("cosmo.datetime.util");
> +dojo.require("cosmo.datetime.timezone.SimpleTimezoneRegistry");
> +dojo.require("cosmo.env");
> +
> +dojo.require("dojo.date.stamp");
> +
> +//Initialization.
> +//TODO - once Dojo implements setUp() and tearDown() move this code  
> there.
> +(function(){
> +var registry = new  
> cosmo 
> .datetime.timezone.SimpleTimezoneRegistry(cosmo.env.getBaseUrl() + "/ 
> js/olson-tzdata/");
> +var D = cosmo.datetime.Date;
> +
> +registry.init(["northamerica"]);
> +cosmo.datetime.timezone.setTimezoneRegistry(registry);
> +
> +doh.register("cosmo.datetime.tests.date",[
> +    function dateConstructor() {
> +        var dt = null;
> +        var dtComp = new Date(2006, 9, 23);
> +
> +        // Floating
> +        dt = new D(2006, 9, 23);
> +        jum.assertEquals(2006, dt.getFullYear());
> +        jum.assertEquals(9, dt.getMonth());
> +        jum.assertEquals(23, dt.getDate());
> +        jum.assertEquals(null, dt.tzId);
> +        jum.assertEquals(false, dt.utc);
> +        jum.assertEquals(dtComp.getTimezoneOffset(),  
> dt.getTimezoneOffset());
> +
> +        dt = new D(2006, 9, 23, 22, 12, 55, 6);
> +        jum.assertEquals(2006, dt.getFullYear());
> +        jum.assertEquals(9, dt.getMonth());
> +        jum.assertEquals(23, dt.getDate());
> +        jum.assertEquals(22, dt.getHours());
> +        jum.assertEquals(12, dt.getMinutes());
> +        jum.assertEquals(55, dt.getSeconds());
> +        jum.assertEquals(6, dt.getMilliseconds());
> +        jum.assertEquals(null, dt.tzId);
> +        jum.assertEquals(false, dt.utc);
> +        jum.assertEquals(dtComp.getTimezoneOffset(),  
> dt.getTimezoneOffset());
> +
> +        dt = new D('10/23/2006');
> +        jum.assertEquals(2006, dt.getFullYear());
> +        jum.assertEquals(9, dt.getMonth());
> +        jum.assertEquals(23, dt.getDate());
> +        jum.assertEquals(null, dt.tzId);
> +        jum.assertEquals(false, dt.utc);
> +        jum.assertEquals(dtComp.getTimezoneOffset(),  
> dt.getTimezoneOffset());
> +
> +        dt = new D(1161659575006);
> +        jum.assertEquals(2006, dt.getFullYear());
> +        jum.assertEquals(9, dt.getMonth());
> +        jum.assertEquals(23, dt.getDate());
> +        jum.assertEquals(null, dt.tzId);
> +        jum.assertEquals(false, dt.utc);
> +        jum.assertEquals(dtComp.getTimezoneOffset(),  
> dt.getTimezoneOffset());
> +
> +        // New York
> +        dt = new D(2006, 9, 23, 'America/New_York');
> +        jum.assertEquals(2006, dt.getFullYear());
> +        jum.assertEquals(9, dt.getMonth());
> +        jum.assertEquals(23, dt.getDate());
> +        jum.assertEquals('America/New_York', dt.tzId);
> +        jum.assertEquals(false, dt.utc);
> +        jum.assertEquals(240, dt.getTimezoneOffset());
> +
> +        dt = new D(2006, 9, 23, 22, 12, 55, 6, 'America/New_York');
> +        jum.assertEquals(2006, dt.getFullYear());
> +        jum.assertEquals(9, dt.getMonth());
> +        jum.assertEquals(23, dt.getDate());
> +        jum.assertEquals(22, dt.getHours());
> +        jum.assertEquals(12, dt.getMinutes());
> +        jum.assertEquals(55, dt.getSeconds());
> +        jum.assertEquals(6, dt.getMilliseconds());
> +        jum.assertEquals('America/New_York', dt.tzId);
> +        jum.assertEquals(false, dt.utc);
> +        jum.assertEquals(240, dt.getTimezoneOffset());
> +
> +        dt = new D('10/23/2006', 'America/New_York');
> +        jum.assertEquals(2006, dt.getFullYear());
> +        jum.assertEquals(9, dt.getMonth());
> +        jum.assertEquals(23, dt.getDate());
> +        jum.assertEquals('America/New_York', dt.tzId);
> +        jum.assertEquals(false, dt.utc);
> +        jum.assertEquals(240, dt.getTimezoneOffset());
> +
> +        // UTC, by timezone
> +        dt = new D(2006, 9, 23, 'Etc/UTC');
> +        jum.assertEquals(2006, dt.getFullYear());
> +        jum.assertEquals(9, dt.getMonth());
> +        jum.assertEquals(23, dt.getDate());
> +        jum.assertEquals('Etc/UTC', dt.tzId);
> +        jum.assertEquals(true, dt.utc);
> +        jum.assertEquals(0, dt.getTimezoneOffset());
> +
> +        dt = new D(2006, 9, 23, 22, 12, 55, 6, 'Etc/UTC');
> +        jum.assertEquals(2006, dt.getFullYear());
> +        jum.assertEquals(9, dt.getMonth());
> +        jum.assertEquals(23, dt.getDate());
> +        jum.assertEquals(22, dt.getHours());
> +        jum.assertEquals(12, dt.getMinutes());
> +        jum.assertEquals(55, dt.getSeconds());
> +        jum.assertEquals(6, dt.getMilliseconds());
> +        jum.assertEquals('Etc/UTC', dt.tzId);
> +        jum.assertEquals(true, dt.utc);
> +        jum.assertEquals(0, dt.getTimezoneOffset());
> +
> +        dt = new D('10/23/2006', 'Etc/UTC');
> +        jum.assertEquals(2006, dt.getFullYear());
> +        jum.assertEquals(9, dt.getMonth());
> +        jum.assertEquals(23, dt.getDate());
> +        jum.assertEquals('Etc/UTC', dt.tzId);
> +        jum.assertEquals(true, dt.utc);
> +        jum.assertEquals(0, dt.getTimezoneOffset());
> +
> +        // UTC, by flag
> +        dt = new D(2006, 9, 23, null, true);
> +        jum.assertEquals(2006, dt.getFullYear());
> +        jum.assertEquals(9, dt.getMonth());
> +        jum.assertEquals(23, dt.getDate());
> +        jum.assertEquals(null, dt.tzId);
> +        jum.assertEquals(true, dt.utc);
> +        jum.assertEquals(0, dt.getTimezoneOffset());
> +
> +        dt = new D(2006, 9, 23, 22, 12, 55, 6, null, true);
> +        jum.assertEquals(2006, dt.getFullYear());
> +        jum.assertEquals(9, dt.getMonth());
> +        jum.assertEquals(23, dt.getDate());
> +        jum.assertEquals(22, dt.getHours());
> +        jum.assertEquals(12, dt.getMinutes());
> +        jum.assertEquals(55, dt.getSeconds());
> +        jum.assertEquals(6, dt.getMilliseconds());
> +        jum.assertEquals(null, dt.tzId);
> +        jum.assertEquals(true, dt.utc);
> +        jum.assertEquals(0, dt.getTimezoneOffset());
> +
> +        dt = new D('10/23/2006', null, true);
> +        jum.assertEquals(2006, dt.getFullYear());
> +        jum.assertEquals(9, dt.getMonth());
> +        jum.assertEquals(23, dt.getDate());
> +        jum.assertEquals(null, dt.tzId);
> +        jum.assertEquals(true, dt.utc);
> +        jum.assertEquals(0, dt.getTimezoneOffset());
> +    },
> +
> +    function dateGetOffset() {
> +        var dt = null;
> +
> +        dt = new D(2006, 9, 29, 1, 59, 'America/Los_Angeles');
> +        jum.assertEquals(420, dt.getTimezoneOffset());
> +
> +        dt = new D(2006, 9, 29, 2, 0, 'America/Los_Angeles');
> +        jum.assertEquals(480, dt.getTimezoneOffset());
> +    },
> +
> +    function dateSetters() {
> +        var dt = null;
> +
> +        dt = new D(2006, 9, 23, 22, 12, 55, 6);
> +        dt.setMilliseconds(2112);
> +        jum.assertEquals(57, dt.getSeconds());
> +        jum.assertEquals(112, dt.getMilliseconds());
> +
> +        dt = new D(2006, 9, 23, 22, 12, 55, 6);
> +        dt.setSeconds(124);
> +        jum.assertEquals(14, dt.getMinutes());
> +        jum.assertEquals(4, dt.getSeconds());
> +
> +        dt = new D(2006, 9, 23, 22, 12, 55, 6);
> +        dt.setMinutes(-20);
> +        jum.assertEquals(21, dt.getHours());
> +        jum.assertEquals(40, dt.getMinutes());
> +
> +        dt = new D(2006, 9, 23, 22, 12, 55, 6);
> +        dt.setHours(52);
> +        jum.assertEquals(25, dt.getDate());
> +        jum.assertEquals(4, dt.getHours());
> +
> +        dt = new D(2006, 9, 23, 22, 12, 55, 6);
> +        dt.setDate(35);
> +        jum.assertEquals(10, dt.getMonth());
> +        jum.assertEquals(4, dt.getDate());
> +
> +        // Leap year
> +        dt = new D(2004, 1, 28);
> +        dt.setDate(29);
> +        jum.assertEquals(1, dt.getMonth());
> +        jum.assertEquals(29, dt.getDate());
> +
> +        // Non-leap-year
> +        dt = new D(2005, 1, 28);
> +        dt.setDate(29);
> +        jum.assertEquals(2, dt.getMonth());
> +        jum.assertEquals(1, dt.getDate());
> +
> +        // Wraparound broken in Safari 2, see WebKit bug 4892
> +        // http://bugs.webkit.org/show_bug.cgi?id=489
> +        // Safari 2 == Safari/412 to Safari/419.3
> +        // http://developer.apple.com/internet/safari/uamatrix.html
> +        if (navigator.userAgent.indexOf('Safari/41') == -1) {
> +            dt = new D(2006, 9, 23, 22, 12, 55, 6);
> +            dt.setMonth(14);
> +            jum.assertEquals(2007, dt.getYear());
> +            jum.assertEquals(2, dt.getMonth());
> +
> +            // Date wraparoud -- Set month to Feb with date of 31st
> +            // should wrap date to March 3rd
> +            dt = new D(2006, 0, 31);
> +            dt.setMonth(1);
> +            jum.assertEquals(2, dt.getMonth());
> +            jum.assertEquals(3, dt.getDate());
> +        }
> +    },
> +
> +    function dateUTCSetters() {
> +        var dt = null;
> +
> +        // UTC date
> +        dt = new D(2006, 9, 23, 22, 12, 55, 6, 'Etc/UTC');
> +        dt.setUTCHours(54);
> +        // Should all be the same -- zero offset
> +        jum.assertEquals(25, dt.getUTCDate());
> +        jum.assertEquals(25, dt.getDate());
> +        jum.assertEquals(6, dt.getUTCHours());
> +        jum.assertEquals(6, dt.getHours());
> +
> +        // Wraparound broken in Safari 2, see WebKit bug 4892
> +        // http://bugs.webkit.org/show_bug.cgi?id=489
> +        // Safari 2 == Safari/412 to Safari/419.3
> +        // http://developer.apple.com/internet/safari/uamatrix.html
> +        if (navigator.userAgent.indexOf('Safari/41') == -1) {
> +            dt = new D(2006, 9, 23, 22, 12, 55, 6, 'America/ 
> Chicago');
> +            dt.setUTCHours(54);
> +            // Should all be the same -- zero offset
> +            jum.assertEquals(25, dt.getUTCDate());
> +            jum.assertEquals(25, dt.getDate());
> +            jum.assertEquals(6, dt.getUTCHours());
> +            jum.assertEquals(11, dt.getHours());
> +        }
> +    }
> +]);
> +})();
> \ No newline at end of file
> Added: cosmo/trunk/cosmo-js/src/cosmo/datetime/tests/module.js (6984  
> => 6985)
>
> --- cosmo/trunk/cosmo-js/src/cosmo/datetime/tests/module.js	 
> 2008-05-15 20:49:01 UTC (rev 6984)
> +++ cosmo/trunk/cosmo-js/src/cosmo/datetime/tests/module.js	 
> 2008-05-15 20:52:03 UTC (rev 6985)
> @@ -0,0 +1,21 @@
> +/* * Copyright 2008 Open Source Applications Foundation *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,  
> software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  
> implied.
> + * See the License for the specific language governing permissions  
> and
> + * limitations under the License.
> + */
> +dojo.provide("cosmo.datetime.tests.module");
> +try{
> +	dojo.require("cosmo.datetime.tests.serialize");
> +    dojo.require("cosmo.datetime.tests.timezone");
> +    dojo.require("cosmo.datetime.tests.date");
> +}catch(e){
> +	doh.debug(e);
> +}
> Added: cosmo/trunk/cosmo-js/src/cosmo/datetime/tests/runTests.html  
> (6984 => 6985)
>
> --- cosmo/trunk/cosmo-js/src/cosmo/datetime/tests/runTests.html	 
> 2008-05-15 20:49:01 UTC (rev 6984)
> +++ cosmo/trunk/cosmo-js/src/cosmo/datetime/tests/runTests.html	 
> 2008-05-15 20:52:03 UTC (rev 6985)
> @@ -0,0 +1,9 @@
> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> +<html>
> +    <head>
> +    <title>Cosmo CORE D.O.H. Unit Test Runner</title>
> +    <meta http-equiv="REFRESH" content="0;url=../../../util/doh/ 
> runner.html?testModule=cosmo.datetime.tests.module"></HEAD>
> +    <BODY>
> +        Redirecting to D.O.H runner.
> +    </BODY>
> +</HTML>
> Copied: cosmo/trunk/cosmo-js/src/cosmo/datetime/tests/serialize.js  
> (from rev 6983, cosmo/trunk/cosmo/src/test/unit/js/cosmo/datetime/ 
> test_serialize.js) (6983 => 6985)
>
> --- cosmo/trunk/cosmo/src/test/unit/js/cosmo/datetime/ 
> test_serialize.js	2008-05-15 16:19:06 UTC (rev 6983)
> +++ cosmo/trunk/cosmo-js/src/cosmo/datetime/tests/serialize.js	 
> 2008-05-15 20:52:03 UTC (rev 6985)
> @@ -0,0 +1,162 @@
> +/*
> + * Copyright 2006-2007 Open Source Applications Foundation
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,  
> software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  
> implied.
> + * See the License for the specific language governing permissions  
> and
> + * limitations under the License.
> +*/
> +
> +dojo.provide("cosmo.datetime.tests.serialize");
> +
> +dojo.require("cosmo.tests.jum");
> +dojo.require("cosmo.datetime.serialize");
> +
> +(function(){
> +
> +/* Makes sure properties specified in the expected match the actual.
> + * Also, makes sure properties not specified in the expected
> + * will resolve to boolean false.
> + */
> +function assertDurationsEqual(id, d1, d2){
> +    if (d1.year) jum.assertEquals(id + ": year", d1.year, d2.year);
> +    else jum.assertFalse(id + ": year", !!d2.year);
> +    if (d1.month) jum.assertEquals(id + ": month", d1.month,  
> d2.month);
> +        else jum.assertFalse(id + ": month", !!d2.month);
> +    if (d1.day) jum.assertEquals(id + ": day", d1.day, d2.day);
> +    else jum.assertFalse(id + ": day", !!d2.day);
> +    if (d1.hour) jum.assertEquals(id + ": hour", d1.hour, d2.hour);
> +    else jum.assertFalse(id + ": hour", !!d2.hour);
> +    if (d1.minute) jum.assertEquals(id + ": minute", d1.minute,  
> d2.minute);
> +    else jum.assertFalse(id + ": minute", !!d2.minute);
> +    if (d1.second) jum.assertEquals(id + ": second", d1.second,  
> d2.second);
> +    else jum.assertFalse(id + ": second", !!d2.second);
> +}
> +
> +doh.register("cosmo.datetime.tests.serialize", [
> +    function fromIso8601(t){
> +        var fI8 = cosmo.datetime.fromIso8601;
> +        doh.debug("gmt");
> +        var d = fI8("20080515T200000Z");
> +        t.is(1210881600000, d.getTime());
> +        doh.debug("honolulu");
> +        d = fI8("20080515T100000", "Pacific/Honolulu");
> +        t.is(1210881600000, d.getTime());
> +        doh.debug("la");
> +        d = fI8("20080515T100000", "America/Los_Angeles");
> +        t.is(1210870800000, d.getTime());
> +
> +    },
> +
> +    function fromIso8601Date(){
> +
> +    },
> +
> +    function fromIso8601Time(){
> +
> +    },
> +
> +    function fromRfc3339(){
> +
> +    },
> +
> +    function addIso8601Duration(){
> +
> +    },
> +
> +    function getIso8601Duration(){
> +
> +    },
> +
> +    function durationHashToIso8601(){
> +        var d1 = {year: 1, month: 2, day: 3, hour: 4, minute: 5,  
> second: 6};
> +        var ds = cosmo.datetime.durationHashToIso8601(d1);
> +        jum.assertEquals("first duration hash wrong",  
> "P1Y2M3DT4H5M6S", ds);
> +
> +        var d2 = {year: 1, month: 2, day: 3};
> +        ds = cosmo.datetime.durationHashToIso8601(d2);
> +        jum.assertEquals("first duration hash wrong", "P1Y2M3D", ds);
> +
> +        var d3 = {hour: 4, minute: 5, second: 6};
> +        ds = cosmo.datetime.durationHashToIso8601(d3);
> +        jum.assertEquals("first duration hash wrong", "PT4H5M6S",  
> ds);
> +
> +    },
> +
> +    function parseIso8601Duration(){
> +        var d1 = {year: 1, month: 2, day: 3, hour: 4, minute: 5,  
> second: 6};
> +        var d2 = cosmo.datetime.parseIso8601Duration(
> +          cosmo.datetime.durationHashToIso8601(d1)
> +          );
> +
> +        assertDurationsEqual("1", d1, d2);
> +
> +        // Make sure things are numbers
> +        jum.assertEquals(2, d2.year + 1);
> +
> +        d1 = {year: 1, month: 2, day: 3};
> +        d2 = cosmo.datetime.parseIso8601Duration(
> +          cosmo.datetime.durationHashToIso8601(d1)
> +          );
> +
> +        assertDurationsEqual("2", d1, d2);
> +
> +        d1 = {hour: 4, minute: 5, second: 6};
> +        d2 = cosmo.datetime.parseIso8601Duration(
> +          cosmo.datetime.durationHashToIso8601(d1)
> +          );
> +
> +        assertDurationsEqual("3", d1, d2);
> +
> +        d1 = {week:1};
> +        d2 = cosmo.datetime.parseIso8601Duration(
> +          cosmo.datetime.durationHashToIso8601(d1)
> +        );
> +
> +        assertDurationsEqual("4", d1, d2);
> +    },
> +
> +   function dojoFromIso8601(){
> +       //we monkey-patched dojo.date.fromIso8601 to fix a bug that  
> occurs when
> +       //parsing dates near DST switchover time. But then we  
> switched over to dojo
> +       //1.0 which didn't have quite the same function, so we wrote  
> our own.
> +       //This verifies that this is no longer a problem.
> +       var string = "20071104T190000Z";
> +       var jsDate = cosmo.datetime.fromIso8601(string);
> +       //should be 19, but unpatched gives 20!
> +       jum.assertEquals("Should be 19", 19,jsDate.getUTCHours());
> +   },
> +
> +    function parseIso8601(){
> +        var p = cosmo.datetime.util.dateParts;
> +
> +        var tests = [["20000101", 2000, 0, 1],
> +                     ["20000131", 2000, 0, 31],
> +                     ["20080229", 2008, 1, 29],
> +                     ["20000101T000000", 2000, 0, 1],
> +                     ["20000505T000000", 2000, 4, 5],
> +                     ["20000101T050505", 2000, 0, 1, 5, 5, 5],
> +                     ["20000101T050505", 2000, 0, 1, 5, 5, 5],
> +                     ["20080108T123045", 2008, 0, 8, 12, 30, 45]
> +                     ];
> +
> +        for (var i in tests){
> +            var test = tests[i];
> +            var dateParts = cosmo.datetime.parseIso8601(test[0]);
> +            jum.assertEquals(test[0] + " year", test[1],  
> dateParts[p.YEAR]);
> +            jum.assertEquals(test[0] + " month", test[2],  
> dateParts[p.MONTH]);
> +            jum.assertEquals(test[0] + " day", test[3],  
> dateParts[p.DAY]);
> +            jum.assertEquals(test[0] + " hour", test[4] || 0,  
> dateParts[p.HOUR]);
> +            jum.assertEquals(test[0] + " minute", test[5] || 0,  
> dateParts[p.MINUTE]);
> +            jum.assertEquals(test[0] + " second", test[6] || 0,  
> dateParts[p.SECOND]);
> +        }
> +    }
> +]);
> +})();
> \ No newline at end of file
> Added: cosmo/trunk/cosmo-js/src/cosmo/datetime/tests/timezone.js  
> (6984 => 6985)
>
> --- cosmo/trunk/cosmo-js/src/cosmo/datetime/tests/timezone.js	 
> 2008-05-15 20:49:01 UTC (rev 6984)
> +++ cosmo/trunk/cosmo-js/src/cosmo/datetime/tests/timezone.js	 
> 2008-05-15 20:52:03 UTC (rev 6985)
> @@ -0,0 +1,238 @@
> +/*
> + * Copyright 2006 Open Source Applications Foundation
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,  
> software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  
> implied.
> + * See the License for the specific language governing permissions  
> and
> + * limitations under the License.
> + */
> +
> +dojo.provide("cosmo.datetime.tests.timezone");
> +dojo.require("cosmo.tests.jum");
> +dojo.require("cosmo.datetime");
> +dojo.require("cosmo.datetime.Date");
> +dojo.require("cosmo.datetime.timezone");
> +dojo.require("cosmo.datetime.timezone.LazyCachingTimezoneRegistry");
> +dojo.require("cosmo.env");
> +//Initialization.
> +//TODO - once Dojo implements setUp() and tearDown() move this code  
> there.
> +
> +(function(){
> +var registry = new  
> cosmo 
> .datetime 
> .timezone.LazyCachingTimezoneRegistry(cosmo.env.getBaseUrl() + "/js/ 
> olson-tzdata/");
> +cosmo.datetime.timezone.setTimezoneRegistry(registry);
> +
> +function getNyTz(){
> +    var timezone = cosmo.datetime.timezone.getTimezone("America/ 
> New_York");
> +    return timezone;
> +}
> +
> +function getUsRs(){
> +    var rs = cosmo.datetime.timezone.getRuleSet("US");
> +    return rs;
> +}
> +
> +doh.register("cosmo.datetime.test.timezone", [
> +                 function getTimezone(){
> +                     var timezone = getNyTz();
> +                     jum.assertTrue(timezone != null);
> +                 },
> +
> +                 function getDateField(){
> +                     var getDateField =  
> cosmo.datetime.timezone._getDateField;
> +                     var cosmoDate = new cosmo.datetime.Date(2006,  
> 11, 10, 12, 33, 30);
> +                     jum.assertEquals(2006, getDateField(cosmoDate,  
> "year"));
> +                     jum.assertEquals(11, getDateField(cosmoDate,  
> "month"));
> +                     jum.assertEquals(10, getDateField(cosmoDate,  
> "date"));
> +                     jum.assertEquals(12, getDateField(cosmoDate,  
> "hours"));
> +                     jum.assertEquals(33, getDateField(cosmoDate,  
> "minutes"));
> +                     jum.assertEquals(30, getDateField(cosmoDate,  
> "seconds"));
> +
> +                     var jsDate = new Date(2006, 11, 10, 12, 33, 30);
> +                     jum.assertEquals(2006, getDateField(jsDate,  
> "year"));
> +                     jum.assertEquals(11, getDateField(jsDate,  
> "month"));
> +                     jum.assertEquals(10, getDateField(jsDate,  
> "date"));
> +                     jum.assertEquals(12, getDateField(jsDate,  
> "hours"));
> +                     jum.assertEquals(33, getDateField(jsDate,  
> "minutes"));
> +                     jum.assertEquals(30, getDateField(jsDate,  
> "seconds"));
> +
> +                     var fullHashDate = { year: 2006,
> +                                          month: 11,
> +                                          date: 10,
> +                                          hours: 12,
> +                                          minutes: 33,
> +                                          seconds: 30};
> +
> +                     jum.assertEquals(2006,  
> getDateField(fullHashDate, "year"));
> +                     jum.assertEquals(11,  
> getDateField(fullHashDate, "month"));
> +                     jum.assertEquals(10,  
> getDateField(fullHashDate, "date"));
> +                     jum.assertEquals(12,  
> getDateField(fullHashDate, "hours"));
> +                     jum.assertEquals(33,  
> getDateField(fullHashDate, "minutes"));
> +                     jum.assertEquals(30,  
> getDateField(fullHashDate, "seconds"));
> +
> +                     var sparseHashDate = { year: 2006,
> +                                            month: 11 };
> +
> +                     jum.assertEquals(2006,  
> getDateField(sparseHashDate, "year"));
> +                     jum.assertEquals(11,  
> getDateField(sparseHashDate, "month"));
> +                     jum.assertEquals(1,  
> getDateField(sparseHashDate, "date"));
> +                     jum.assertEquals(0,  
> getDateField(sparseHashDate, "hours"));
> +                     jum.assertEquals(0,  
> getDateField(sparseHashDate, "minutes"));
> +                     jum.assertEquals(0,  
> getDateField(sparseHashDate, "seconds"));
> +                 },
> +
> +                 function compareDates(){
> +                     var compareDates =  
> cosmo.datetime.timezone._compareDates;
> +                     var jsDate1 = new Date(2006, 11, 10, 12, 33,  
> 30);
> +                     var jsDate2 = new Date(2007, 11, 10, 12, 33,  
> 30);
> +                     jum.assertTrue(compareDates(jsDate1, jsDate2)  
> < 0);
> +
> +                     jsDate1 = new Date(2006, 11, 10, 12, 33, 30);
> +                     jsDate2 = new Date(2006, 11, 10, 12, 33, 30);
> +                     jum.assertTrue(compareDates(jsDate1, jsDate2)  
> == 0);
> +
> +                     jsDate1 = new Date(2006, 11, 10, 12, 33, 31);
> +                     jsDate2 = new Date(2006, 11, 10, 12, 33, 30);
> +                     jum.assertTrue(compareDates(jsDate1, jsDate2)   
> > 0);
> +
> +                     jsDate1 = new Date(2006, 11, 10, 13, 33, 31);
> +                     jsDate2 = new Date(2006, 11, 10, 12, 33, 31);
> +                     jum.assertTrue(compareDates(jsDate1, jsDate2)   
> > 0);
> +
> +                     var sparseHashDate = { year: 2006,
> +                                            month: 11 };
> +                     jsDate2 = new Date(2006, 11, 1, 1, 1, 1, 1);
> +                     jum.assertTrue(compareDates(sparseHashDate,  
> jsDate2) < 0);
> +                 },
> +
> +                 function getZoneItemForDate(){
> +                     var tz = getNyTz();
> +                     var date = new Date(2006, 1, 1);
> +                     var zoneItem = tz._getZoneItemForDate(date);
> +                     jum.assertEquals(null, zoneItem.untilDate);
> +
> +                     date = new Date(1966, 11, 31);
> +                     zoneItem = tz._getZoneItemForDate(date);
> +                     jum.assertEquals(1967, zoneItem.untilDate.year);
> +
> +                     date = new Date(1800, 1, 1);
> +                     zoneItem = tz._getZoneItemForDate(date);
> +                     jum.assertEquals(1883, zoneItem.untilDate.year);
> +
> +                     date = new Date(1920, 1, 1);
> +                     zoneItem = tz._getZoneItemForDate(date);
> +                     jum.assertEquals(1942, zoneItem.untilDate.year);
> +                 },
> +
> +                 function getRulesForYear(){
> +                     var rs = getUsRs();
> +                     var rules = rs._getRulesForYear(1999);
> +                     jum.assertEquals(2, rules.length);
> +                     jum.assertEquals(1967, rules[0].startYear);
> +                 },
> +
> +                 function DayGreateThanNForMonthAndYear(){
> +                     var func =  
> cosmo.datetime.timezone._getDayGreaterThanNForMonthAndYear;
> +
> +                     //"get me the date of the first thursday that  
> is greater than or equal to the 8th in November"
> +                     var date = func(8, 4, 10, 2006);
> +                     jum.assertEquals(9, date);
> +
> +                     //"get me the date of the first wednesday that  
> is greater than or equal to the 8th in November"
> +                     date = func(8, 3, 10, 2006);
> +                     jum.assertEquals(8, date);
> +
> +                     //"get me the date of the first tuesday that  
> is greater than or equal to the 8th in November"
> +                     date = func(8, 2, 10, 2006);
> +                     jum.assertEquals(14, date);
> +                 },
> +
> +                 function DayLessThanNForMonthAndYear(){
> +                     var func =  
> cosmo.datetime.timezone._getDayLessThanNForMonthAndYear;
> +
> +                     //"get me the date of the last thursday that  
> is less than or equal to the 8th in November"
> +                     var date = func(8,4,10,2006);
> +                     jum.assertEquals(2, date);
> +
> +                     //"get me the date of the last wednesday that  
> is less than or equal to the 8th in November"
> +                     date = func(8,3,10,2006);
> +                     jum.assertEquals(8, date);
> +
> +                     //"get me the date of the last tuesday that is  
> less than or equal to the 8th in November"
> +                     date = func(8,2,10,2006);
> +                     jum.assertEquals(7, date);
> +                 },
> +
> +                 function getStartDateForYear(){
> +                     //to test:  
> cosmo.datetime.timezone.Rule.prototype._getStartDateForYear =  
> function(year)
> +                     var rs = getUsRs();
> +                     var sorter = function(a,b){return a.startMonth  
> - b.startMonth;};
> +
> +                     var rules = rs._getRulesForYear(1967);
> +                     rules.sort(sorter);
> +                     var startDate =  
> rules[0]._getStartDateForYear(2006);
> +
> +                     //for sanity's sake, make sure it's APR
> +                     jum.assertEquals(3, startDate.month);
> +
> +                     //rule says Apr, lastSun - last sunday in  
> april which is the 30th
> +                     jum.assertEquals(30, startDate.date);
> +
> +                     rules = rs._getRulesForYear(1974);
> +                     rules.sort(sorter);
> +                     startDate = rules[0]._getStartDateForYear(1974);
> +
> +                     //rule says "jan 6"
> +                     jum.assertEquals(0, startDate.month);
> +                     jum.assertEquals(6, startDate.date);
> +
> +                     rules = rs._getRulesForYear(2007);
> +                     rules.sort(sorter);
> +                     startDate = rules[0]._getStartDateForYear(2007);
> +
> +                     //rule sun>=8 - first sunday after or on the  
> eighth which is the 11th
> +                     jum.assertEquals(2, startDate.month);
> +                     jum.assertEquals(11, startDate.date);
> +                 },
> +
> +                 function getOffsetInMinutes(){
> +                     var timezone = getNyTz();
> +                     var date;
> +                     var offset;
> +
> +                     date = new Date(2006, 1, 1);
> +                     offset = timezone.getOffsetInMinutes(date);
> +                     jum.assertEquals(-300, offset);
> +
> +                     date = new Date(2006, 3, 1);
> +                     offset = timezone.getOffsetInMinutes(date);
> +                     jum.assertEquals(-300, offset);
> +
> +                     date = new Date(2006, 3, 2, 1, 59, 69);
> +                     offset = timezone.getOffsetInMinutes(date);
> +                     jum.assertEquals(-300, offset);
> +
> +                     date = new Date(2006, 3, 2, 3, 0, 0);
> +                     offset = timezone.getOffsetInMinutes(date);
> +                     jum.assertEquals(-240, offset);
> +                 },
> +
> +                 function getRuleForDate(){
> +                     //var tz =  
> cosmo.datetime.timezone._timezoneRegistry.getTimezone("America/ 
> Barbados");
> +                     var date = new Date(2006, 1, 1);
> +                     var ruleSet =  
> cosmo.datetime.timezone.getRuleSet("Barb");
> +                     var rule = ruleSet._getRuleForDate(date);
> +                     jum.assertTrue(rule != null);
> +                     jum.assertTrue(rule.startYear == 1980);
> +                     jum.assertTrue(rule.letter == "S");
> +
> +                 }
> +             ]);
> +
> + })();
> \ No newline at end of file
> Modified: cosmo/trunk/cosmo-js/src/cosmo/env.js (6984 => 6985)
>
> --- cosmo/trunk/cosmo-js/src/cosmo/env.js	2008-05-15 20:49:01 UTC  
> (rev 6984)
> +++ cosmo/trunk/cosmo-js/src/cosmo/env.js	2008-05-15 20:52:03 UTC  
> (rev 6985)
> @@ -258,7 +258,7 @@
>  }
>
>  //initialize from dojo.config
> -cosmo.env.setBaseUrl(dojo.config['serverBaseUrl']);
> +cosmo.env.setBaseUrl(dojo.config['serverBaseUrl'] ||  
> dojo.moduleUrl("cosmo", "../.."));
>   
> cosmo 
> .env.setStaticBaseUrlTemplate(dojo.config['staticBaseUrlTemplate']);
>  cosmo.env.setStaticBaseUrlRange(dojo.config['staticBaseUrlRange']);
>
> Modified: cosmo/trunk/cosmo-js/src/cosmo/service/translators/eim.js  
> (6984 => 6985)
>
> --- cosmo/trunk/cosmo-js/src/cosmo/service/translators/eim.js	 
> 2008-05-15 20:49:01 UTC (rev 6984)
> +++ cosmo/trunk/cosmo-js/src/cosmo/service/translators/eim.js	 
> 2008-05-15 20:52:03 UTC (rev 6985)
> @@ -213,7 +213,7 @@
>          for (var i = 0; i < nodes.length; i++){
>              var node = nodes[i];
>              if ((node.nodeType != 1) || (tagName && tagName !=  
> node.tagName)) continue;
> -            var classNode = node.getAttributeNode("class")
> +            var classNode = node.getAttributeNode("class");
>              if (classNode && (classNode.nodeValue == className)){
>                  returnNodes.push(node);
>              }
> @@ -233,7 +233,7 @@
>      },
>
>      collectionXmlToCollection: function (collectionXml){
> -        return collection = new cosmo.model.Collection(
> +        return new cosmo.model.Collection(
>              {
>                  displayName:  
> cosmo.util.html.getElementsByTagName(collectionXml, "atom", "title")
>                      [0].firstChild.nodeValue
> @@ -317,7 +317,7 @@
>              var entry = entries[i];
>              var uuid = this.getEntryUuid(entry);
>              if (!uuid.split(":")[1]){
> -                items[uuid] = this.entryToItem(entry)
> +                items[uuid] = this.entryToItem(entry);
>              }
>              else {
>                  mods[uuid] = entry;
> @@ -398,15 +398,15 @@
>          for (recordName in recordSet.records){
>          with (cosmo.service.eim.constants){
>
> -           var record = recordSet.records[recordName]
> +           var record = recordSet.records[recordName];
>
>             switch(recordName){
>
>             case prefix.ITEM:
> -                
> note.initializeProperties(this.itemRecordToItemProps(record),  
> {noDefaults: true})
> +                
> note.initializeProperties(this.itemRecordToItemProps(record),  
> {noDefaults: true});
>                 break;
>             case prefix.NOTE:
> -                
> note.initializeProperties(this.noteRecordToNoteProps(record),  
> {noDefaults: true})
> +                
> note.initializeProperties(this.noteRecordToNoteProps(record),  
> {noDefaults: true});
>                 break;
>             case prefix.MODBY:
>                 note.setModifiedBy(new  
> cosmo.model.ModifiedBy(this.modbyRecordToModbyProps(record)));
> @@ -574,7 +574,7 @@
>          } else {
>              throw new  
> cosmo.service.translators.exception.ModelToRecordSetException(
>                  "note is neither a Note nor a NoteOccurrence, don't  
> know how to translate."
> -            )
> +            );
>          }
>      },
>
> @@ -616,7 +616,7 @@
>          var modification =  
> noteOccurrence 
> .getMaster().getModification(noteOccurrence.recurrenceId);
>          var records = {
>              modby: this.noteToModbyRecord(noteOccurrence)
> -        }
> +        };
>          if (this.modificationHasItemModifications(modification))
>              records.item =   
> this.modifiedOccurrenceToItemRecord(noteOccurrence);
>          else records.item = this.generateEmptyItem(noteOccurrence);
> @@ -648,7 +648,7 @@
>
>      modificationHasItemModifications: function (modification){
>          var props = modification.getModifiedProperties();
> -        return (props.displayName || props.triageRank ||  
> props.triageStatus || props.autoTriage)
> +        return (props.displayName || props.triageRank ||  
> props.triageStatus || props.autoTriage);
>      },
>
>      noteToItemRecord: function(note){
> @@ -663,7 +663,7 @@
>      },
>
>      modifiedOccurrenceToItemRecord: function(modifiedOccurrence){
> -        var modification =  
> modifiedOccurrence 
> .getMaster().getModification(modifiedOccurrence.recurrenceId)
> +        var modification =  
> modifiedOccurrence 
> .getMaster().getModification(modifiedOccurrence.recurrenceId);
>          var props = modification.getModifiedProperties();
>          props.uuid = this.getUid(modifiedOccurrence);
>          var record = this.propsToItemRecord(props);
> @@ -682,7 +682,7 @@
>              "triage",
>              "hasBeenSent",
>              "needsReply"
> -        ]
> +        ];
>          return record;
>      },
>
> @@ -702,7 +702,7 @@
>                      uuid: [type.TEXT, props.uuid]
>                  },
>                  fields: fields
> -            }
> +            };
>          }
>
>      },
> @@ -730,7 +730,7 @@
>
>
>      modifiedOccurrenceToNoteRecord: function(modifiedOccurrence){
> -        var modification =  
> modifiedOccurrence 
> .getMaster().getModification(modifiedOccurrence.recurrenceId)
> +        var modification =  
> modifiedOccurrence 
> .getMaster().getModification(modifiedOccurrence.recurrenceId);
>          var props = modification.getModifiedProperties();
>          props.uuid = this.getUid(modifiedOccurrence);
>          var record = this.propsToNoteRecord(props);
> @@ -762,13 +762,13 @@
>                      uuid: [type.TEXT, props.uuid]
>                  },
>                  fields: fields
> -            }
> +            };
>          }
>      },
>
>      noteToMailRecord: function(note){
>          var props = {};
> -        stamp = note.getMailStamp();
> +        var stamp = note.getMailStamp();
>          props.messageId = stamp.getMessageId();
>          props.headers = stamp.getHeaders();
>          props.fromAddress = stamp.getFromAddress();
> @@ -819,21 +819,20 @@
>              if (props.inReplyTo !== undefined) fields.inReplyTo =  
> [type.TEXT, props.inReplyTo];
>              if (props.references !== undefined) fields.references =  
> [type.CLOB, props.references];
>
> -            return record = {
> +            return {
>                  prefix: prefix.MAIL,
>                  ns: ns.MAIL,
>                  key: {
>                      uuid: [type.TEXT, props.uuid]
>                  },
>                  fields: fields
> -            }
> -            return record;
> +            };
>          }
>      },
>
>      noteToEventRecord: function(note){
>          var props = {};
> -        stamp = note.getEventStamp();
> +        var stamp = note.getEventStamp();
>          props.allDay = stamp.getAllDay();
>          props.anyTime = stamp.getAnyTime();
>          props.startDate = stamp.getStartDate();
> @@ -875,14 +874,14 @@
>              if (props.exdates && props.exdates.length != 0)  
> fields.exdate =
>                  [type.TEXT, this.exdatesToEim(props.exdates,  
> props.startDate, props.allDay, props.anyTime)];
>
> -            return record = {
> +            return {
>                  prefix: prefix.EVENT,
>                  ns: ns.EVENT,
>                  key: {
>                      uuid: [type.TEXT, props.uuid]
>                  },
>                  fields: fields
> -            }
> +            };
>          }
>
>
> @@ -923,7 +922,7 @@
>                  },
>                  fields: {}
>
> -            }
> +            };
>          }
>
>      },
> @@ -940,7 +939,7 @@
>                      action: [type.INTEGER,  
> note.getModifiedBy().getAction()],
>                      timestamp: [type.DECIMAL, new Date().getTime()/ 
> 1000]
>                  }
> -            }
> +            };
>          }
>      },
>
> @@ -968,7 +967,7 @@
>                      new  
> cosmo.model.Duration(record.fields.duration[1]);
>              if (record.fields.location) properties.location =  
> record.fields.location[1];
>              if (record.fields.rrule) properties.rrule =  
> this.parseRRule(record.fields.rrule[1], properties.startDate);
> -            if (record.fields.exrule) properties.exrule =  
> this.parseRRule(record.fields.exrule[1]), properties.startDate;
> +            if (record.fields.exrule) properties.exrule =  
> this.parseRRule(record.fields.exrule[1], properties.startDate);
>              if (record.fields.exdate) properties.exdates =  
> this.parseExdate(record.fields.exdate[1]);
>              if (record.fields.status) properties.status =  
> record.fields.status[1];
>          }
> @@ -990,7 +989,7 @@
>              if (record.fields.toAddress) properties.toAddress =  
> record.fields.toAddress[1];
>              if (record.fields.ccAddress) properties.ccAddress =  
> record.fields.ccAddress[1];
>              if (record.fields.bccAddress) properties.bccAddress =  
> record.fields.bccAddress[1];
> -            if (record.fields.originators) properties.originators =  
> record.fields.originators[1]
> +            if (record.fields.originators) properties.originators =  
> record.fields.originators[1];
>              if (record.fields.dateSent) properties.dateSent =  
> record.fields.dateSent[1]; //TODO: parse
>              if (record.fields.inReplyTo) properties.inReplyTo =  
> record.fields.inReplyTo[1];
>              if (record.fields.references) properties.references =  
> record.fields.references[1];
> @@ -1085,11 +1084,11 @@
>              var recurrenceRuleList = [
>                 ";FREQ=",
>                   
> this.rruleFrequenciesToRruleConstants[rrule.getFrequency()]
> -             ]
> +            ];
>               var endDate = rrule.getEndDate();
>               if (endDate){
>                  recurrenceRuleList.push(";UNTIL=");
> -                var dateString =  
> this._createRecurrenceEndDateString(rrule.getEndDate())
> +                 var dateString =  
> this._createRecurrenceEndDateString(rrule.getEndDate());
>                  recurrenceRuleList.push(dateString);
>               }
>
> @@ -1106,7 +1105,7 @@
>          date.setMinutes(59);
>          date.setSeconds(59);
>          date = date.createDateForTimezone("utc");
> -        return dojox.date.posix.strftime(date, "%Y%m%dT%H%M%SZ")
> +        return dojox.date.posix.strftime(date, "%Y%m%dT%H%M%SZ");
>      },
>
>      rrlePropsToICal: function (rProps, startDate){
> @@ -1140,13 +1139,13 @@
>          if (!exdate) return null;
>          return dojo.map(
>                  exdate.split(":")[1].split(","),
> -                function (exdate, index) {return  
> cosmo.datetime.fromIso8601(exdate)}
> +                function (exdate, index) {return  
> cosmo.datetime.fromIso8601(exdate);}
>           );
>      },
>
>      //Snagged from dojo.cal.iCalendar
>      parseRRuleToHash: function (rule){
> -        var rrule = {}
> +        var rrule = {};
>          var temp = rule.split(";");
>          for (var y=0; y<temp.length; y++) {
>              if (temp[y] != ""){
> @@ -1250,7 +1249,7 @@
>          } else {
>              var RecurrenceRule = cosmo.model.RRULE_FREQUENCIES;
>              var Recur = this.rruleConstants;
> -            var recurrenceRule = {}
> +            var recurrenceRule = {};
>              // Set frequency
>              if (rprops.freq == Recur.WEEKLY) {
>                  if (rprops.interval == 1 || !rprops.interval){
> Added: cosmo/trunk/cosmo-js/src/cosmo/tests/jum.js (6984 => 6985)
>
> --- cosmo/trunk/cosmo-js/src/cosmo/tests/jum.js	2008-05-15 20:49:01  
> UTC (rev 6984)
> +++ cosmo/trunk/cosmo-js/src/cosmo/tests/jum.js	2008-05-15 20:52:03  
> UTC (rev 6985)
> @@ -0,0 +1,49 @@
> +/*
> + * Copyright 2008 Open Source Applications Foundation
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,  
> software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  
> implied.
> + * See the License for the specific language governing permissions  
> and
> + * limitations under the License.
> +*/
> +dojo.provide("cosmo.tests.jum");
> +
> +(function(){
> +// Object to provide compatibility with old jum framework
> +var JUM = function(){
> +};
> +
> +function _JUM_first_arg_string_func(n, name){
> +    return function(){
> +        var args = arguments;
> +        var s = null;
> +        if (arguments.length == n){
> +            args = arguments;
> +        } else if (arguments.length == n + 1){
> +            s = arguments[0];
> +            args = Array.prototype.slice.apply(arguments, [1]);
> +        }
> +        try {
> +            return doh[name].apply(doh, args);
> +        } catch (e){
> +            console.log("Test failure message was: " + s);
> +            throw e;
> +        }
> +    };
> +}
> +
> +JUM.prototype = {
> +    assertTrue: _JUM_first_arg_string_func(1, "assertTrue"),
> +    assertFalse: _JUM_first_arg_string_func(1, "assertFalse"),
> +    assertEquals: _JUM_first_arg_string_func(2, "assertEqual")
> +}
> +
> +dojo.global.jum = new JUM();
> +})();
> \ No newline at end of file
> Modified: cosmo/trunk/cosmo-js/src/cosmo/testutils.js (6984 => 6985)
>
> --- cosmo/trunk/cosmo-js/src/cosmo/testutils.js	2008-05-15 20:49:01  
> UTC (rev 6984)
> +++ cosmo/trunk/cosmo-js/src/cosmo/testutils.js	2008-05-15 20:52:03  
> UTC (rev 6985)
> @@ -17,35 +17,6 @@
>  dojo.provide("cosmo.testutils");
>  dojo.require("dojox.uuid.generateRandomUuid");
>
> -// Object to provide compatibility with old jum framework
> -JUM = function(){
> -}
> -
> -function _JUM_first_arg_string_func(n, name){
> -    return function(){
> -        var args = arguments;
> -        var s = null;
> -        if (arguments.length == n){
> -            args = arguments;
> -        } else if (arguments.length == n + 1){
> -            s = arguments[0];
> -            args = Array.prototype.slice.apply(arguments, [1]);
> -        }
> -        try {
> -            return doh[name].apply(doh, args);
> -        } catch (e){
> -            console.log("Test failure message was: " + s);
> -            throw e;
> -        }
> -    }
> -}
> -
> -JUM.prototype = {
> -    assertTrue: _JUM_first_arg_string_func(1, "assertTrue"),
> -    assertFalse: _JUM_first_arg_string_func(1, "assertFalse"),
> -    assertEquals: _JUM_first_arg_string_func(2, "assertEqual")
> -}
> -
>  dojo.require("cosmo.cmp");
>  dojo.require("cosmo.util.auth");
>
>
> _______________________________________________
> Commits-Cosmo mailing list
> Commits-Cosmo at osafoundation.org
> http://lists.osafoundation.org/cgi-bin/mailman/listinfo/commits-cosmo

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osafoundation.org/pipermail/cosmo-dev/attachments/20080515/58f51b56/attachment.html


More information about the cosmo-dev mailing list