#339 ✓resolved
Bernerd Schaefer

Windows UTC Offset

Reported by Bernerd Schaefer | June 3rd, 2008 @ 05:44 PM

Comments and changes to this ticket

  • Bernerd Schaefer

    Bernerd Schaefer June 3rd, 2008 @ 05:47 PM

    I looked into this a bit today. Here's the solution I came up with for do_postgres.

    It would be great for someone with Windows to see if this actually works. If so, we can clean it up and put in the other adapters.

  • Bernerd Schaefer

    Bernerd Schaefer June 11th, 2008 @ 11:45 AM

    • State changed from “new” to “open”

    This should hopefully work better, now. It still remains to figure out how to handle daylight savings time, but I don't /think/ there should be windows problems. Do let me know.

  • Bernerd Schaefer

    Bernerd Schaefer June 5th, 2008 @ 10:49 AM

    • Title changed from “Windows UTF Offset” to “Windows UTC Offset”
  • Luis Lavena

    Luis Lavena June 5th, 2008 @ 06:36 PM

    It seems to be working, and could be applied, but got this error from it:

    1)
    'DataObjects::Postgres::Reader should return DateTimes using the current locale's Time Zone for TIMESTAMP WITHOUT TIME ZONE fields' FAILED
    expected: "2008-06-06T01:33:04+02:00",
         got: "2008-06-06T01:33:04+01:00" (using ==)
    D:/Users/Luis/projects/oss/datamapper/do/do_postgres/spec/do_postgres_spec.rb:198
    D:/Users/Luis/projects/oss/datamapper/do/do_postgres/spec/spec_helper.rb:74:in `select'
    D:/Users/Luis/projects/oss/datamapper/do/do_postgres/spec/do_postgres_spec.rb:197
    

    It seems is taking one hour away from the timezone information.

    Moving to a timezone with no offset got another round of failures:

    
    1)
    'DataObjects::Postgres::Reader should return DateTimes using the current locale's Time Zone for TIMESTAMP WITHOUT TIME ZONE fields' FAILED
    expected: "2008-06-06T00:34:20+01:00",
         got: "2008-06-06T00:34:20+00:00" (using ==)
    D:/Users/Luis/projects/oss/datamapper/do/do_postgres/spec/do_postgres_spec.rb:198
    D:/Users/Luis/projects/oss/datamapper/do/do_postgres/spec/spec_helper.rb:74:in `select'
    D:/Users/Luis/projects/oss/datamapper/do/do_postgres/spec/do_postgres_spec.rb:197
    
    2)
    'DataObjects::Postgres::Reader should return DateTimes using the current locale's Time Zone TIMESTAMP WITH TIME ZONE fields' FAILED
    expected: "2008-06-06T00:34:20+01:00",
         got: "2008-06-06T01:34:20+02:00" (using ==)
    D:/Users/Luis/projects/oss/datamapper/do/do_postgres/spec/do_postgres_spec.rb:207
    D:/Users/Luis/projects/oss/datamapper/do/do_postgres/spec/spec_helper.rb:74:in `select'
    D:/Users/Luis/projects/oss/datamapper/do/do_postgres/spec/do_postgres_spec.rb:206
    
    3)
    'DataObjects::Postgres::Reader should return DateTimes using the current locale's Time Zone if they were inserted using a different timezone' FAILED
    expected: "2008-06-06T00:34:20+01:00",
         got: "2008-06-06T01:34:20+02:00" (using ==)
    D:/Users/Luis/projects/oss/datamapper/do/do_postgres/spec/do_postgres_spec.rb:228
    D:/Users/Luis/projects/oss/datamapper/do/do_postgres/spec/spec_helper.rb:74:in `select'
    D:/Users/Luis/projects/oss/datamapper/do/do_postgres/spec/do_postgres_spec.rb:226
    D:/Users/Luis/projects/oss/datamapper/do/do_postgres/spec/do_postgres_spec.rb:223:in `each'
    D:/Users/Luis/projects/oss/datamapper/do/do_postgres/spec/do_postgres_spec.rb:223
    
    
  • Bernerd Schaefer

    Bernerd Schaefer June 9th, 2008 @ 12:05 PM

    Luis,

    I think I have resolved all of these timezone issues for do_postgres.

    http://github.com/sam/do/commit/...

    If you can confirm that this does work for windows, I'll port it to do_mysql and do_sqlite, and we'll be set.

    Thanks,

    Bernerd

  • Luis Lavena

    Luis Lavena June 9th, 2008 @ 01:34 PM

    Close, only when timezone < 0:

    UTC-3 (Buenos Aires, my default timezone) works without issues,

    With Timezone set +1 (Paris), instead:

    
    1)
    'DataObjects::Postgres::Reader should return DateTimes using the current locale's Time Zone for TIMESTAMP WITHOUT TIME ZONE fields' FAILED
    expected: "2008-06-09T20:26:51+02:00",
         got: "2008-06-09T20:26:51+03:00" (using ==)
    
    

    I'm looking at it right now, I'll jump into #irc in a minute.

  • Bernerd Schaefer

    Bernerd Schaefer June 9th, 2008 @ 03:55 PM

    Luis, is this on Windows? How are you changing the timezone? Do you know how the local timezone is calculated?

    I ask because I wrote a script to run the specs with every timezone in the zoneinfo database on my OS X box, and all pass except Asia/Riyadh87-9 and Mideast/Riyadh87-9.

  • Luis Lavena

    Luis Lavena June 9th, 2008 @ 04:46 PM

    Yes.

    Tried specs with timezone -3 (Buenos Aires), changed from Timezone in Regional Settings.

    Tried also with timezone +1, added some debug information:

    
    		// Get localtime
    		time(&rawtime);
    		timeinfo = localtime(&rawtime);
    
    		fprintf(stderr, "localtime->tm_isdst = %d\n", timeinfo->tm_isdst);
    		is_dst = timeinfo->tm_isdst * 3600;
    
    		// Reset to GM Time
    		timeinfo = gmtime(&rawtime);
    
    		fprintf(stderr, "gmtime->tm_isdst = %d\n", timeinfo->tm_isdst);
    		gmt_offset = mktime(timeinfo) - rawtime;
    
    		fprintf(stderr, "(before) gmt_offset = %d\n", gmt_offset);
    
    		if ( is_dst > 0 )
    			gmt_offset -= is_dst;
    
    		fprintf(stderr, "(after) gmt_offset = %d\n", gmt_offset);
    
    

    Those are the results:

    
    localtime->tm_isdst = 1
    gmtime->tm_isdst = 0
    (before) gmt_offset = -3600
    (after) gmt_offset = -7200
    
    
  • Bernerd Schaefer

    Bernerd Schaefer June 10th, 2008 @ 09:37 AM

    You said this was for Paris, right? Because +2 is actually correct, since there is currently daylight savings time in Central Europe.

    http://www.timeanddate.com/libra...

  • Luis Lavena

    Luis Lavena June 10th, 2008 @ 10:14 AM

    Yes, you're correct, but:

    http://www.timeanddate.com/world...

    
    UTC/GMT Offset	
    Standard time zone:	UTC/GMT +1 hour
    Daylight saving time:	+1 hour
    Current time zone offset:	UTC/GMT +2 hours
    
    

    But now, check the following IRB output:

    
    irb(main):001:0> Time.now
    => Tue Jun 10 17:10:50 +0200 2008
    irb(main):002:0> Time.now.utc
    => Tue Jun 10 15:11:00 UTC 2008
    
    

    The expected value is correct, but the returned value from do_postgres is not, all due the increment of hour in is_dst condition.

    Sorry I cannot take a deeper look at it until weekend, been extremely busy the past days :-(

  • Luis Lavena

    Luis Lavena June 21st, 2008 @ 08:23 AM

    • Title changed from “Windows UTC Offset” to “Windows UTF Offset”

    Thank you Bernerd for you hard work, but after extlib (new Pooling being merged) I can no longer run specs for do_postgres:

    
    

    deadlock 0x28b5580: sleep:- (main) - D:/Users/Luis/ruby/ruby-186-p114-MINGW-rubygems-111/lib/ruby/gems/1.8/gems/extlib-0.9.2/lib/extlib/pooling.rb:57

    deadlock 0x2d14898: sleep:- - D:/Users/Luis/ruby/ruby-186-p114-MINGW-rubygems-111/lib/ruby/gems/1.8/gems/extlib-0.9.2/lib/extlib/pooling.rb:35

    Too bad since they looked good, except, as we discussed the DST (daylight saving) issue.

    Please let me know when those changes will be part of the other adapters (sqlite3 and mysql).

    Thanks.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) November 30th, 2008 @ 02:29 AM

    • Tag set to bug, dataobjects
    • Assigned user cleared.

    Luis, is this still the case for you with the latest extlib? I know we made some fixes to dkubb/extlib to resolve some of the deadlocking issues. If this was still a blocker for you, and you're using the latest extlib gem, I suppose we could backport those specific changes to sam/extlib.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) December 1st, 2008 @ 06:18 PM

    • Assigned user set to “Luis Lavena”

    Luis, I just wondered if you'd mind looking at this and seeing if we're fixed the extlib problems you were having in dkubb/extlib? I have no problem backporting it prior to a release, but it'd be nice to know if it were fixed for you first.

  • Luis Lavena

    Luis Lavena December 1st, 2008 @ 06:58 PM

    • Title changed from “Windows UTF Offset” to “Windows UTC Offset”

    Hey Dan,

    Looks like pooling issues has been resolved in your fork.

    Both straight and reverse specs worked.

    However, I have merge issues with sam/extlib.

    I'm about to test it against latest DataObjects and let you know.

  • Luis Lavena

    Luis Lavena December 1st, 2008 @ 07:31 PM

    Just checked DataObjects with dkubb/extlib:

    Luis@KEORE (D:\Users\Luis\projects\oss\datamapper\do.git\data_objects)
    $ spec spec
    .................JDBC URLs (connection strings) are only for use with JRuby
    .......................................An expectation of :flush! was set on nil. Called from D:/Users/Luis/projects/oss/datamapper/do.git/data_objects/spec/support/pooling_spec.rb:325. Use allow_message_expectations_on_nil to disable warnings.
    ..............
    
    Finished in 6.125 seconds
    
    
    And reverse specs:
    Luis@KEORE (D:\Users\Luis\projects\oss\datamapper\do.git\data_objects)
    $ spec -R spec
    .............An expectation of :flush! was set on nil. Called from D:/Users/Luis/projects/oss/datamapper/do.git/data_objects/spec/support/pooling_spec.rb:325. Use allow_message_expectations_on_nil to disable warnings.
    .......................................JDBC URLs (connection strings) are only for use with JRuby
    ..................
    
    Finished in 6.172 seconds
    
    As you can see, DO still has some issues, when I get those working (without the failure described there), I'll move into the adapters.
  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) December 2nd, 2008 @ 04:28 AM

    Luis, that is good. In the meantime, while you work on this, we'll backport the fixes for this from dkubb/extlib to sam/extlib to prepare for the next gem release.

  • Luis Lavena

    Luis Lavena December 2nd, 2008 @ 07:25 AM

    Cool, working on that, this just showed up.

    1)
    Spec::Mocks::MockExpectationError in 'Pooling::ResourcePool#dispose_outdated releases and thus
    disposes outdated instances'
    # expected :release with (#) once, but received it 0 times
    D:/Users/Luis/projects/oss/datamapper/do.git/data_objects/spec/support/pooling_spec.rb:370
    
    
    http://pastie.org/328706 Pooling is weird, maybe it doesn't work during daylight? ;-)
  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) January 8th, 2009 @ 04:35 AM

    • State changed from “open” to “unconfirmed”
    • Assigned user changed from “Luis Lavena” to “Dirkjan Bussink”

    Dirkjan, I was wondering if you could look at this?

  • Dirkjan Bussink

    Dirkjan Bussink July 23rd, 2009 @ 11:51 AM

    • State changed from “unconfirmed” to “resolved”

    Dunno if this still is an issue, looks like it was resolved with the whole refactoring for Windows. If this is still an issue, please create a new ticket describing the exact issue.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Attachments

Pages