Skip to content

Synchronize timezone with PostgreSQL #646

Closed

Description

@roji

We should consider sending a TIME ZONE startup parameter when connecting to PostgreSQL. This parameter affects how timestamp with time zone is rendered in text encoding (but not binary), as well as some other time-related functions etc.

If this parameter isn't set, the server's timezone is used, whatever that is. As long as the client and server happen to be in the same time zone that may be OK, but if not it seems extremely undesirable.

Another note from the PostgreSQL docs:

The PGTZ environment variable is used by libpq clients to send a SET TIME ZONE command to the server upon connection.

We should probably respect this environment variable as well (but should we also send the system timezone if this variable isn't set?)

Any comments?

EDIT: to handle cases where the user modifies the TIME ZONE manually (example), we should also intercept changes to TimeZone, and impact timestamptz conversions...

Activity

  1. franciscojunior commented on Jun 17, 2015

    @franciscojunior
    Member

    I think we could add this option.

    As this would help users get a better experience when using Npgsql.

    +1

    On Wed, Jun 17, 2015 at 10:38 AM, Shay Rojansky [email protected]
    wrote:

    We should consider sending a TIME ZONE startup parameter when connecting
    to PostgreSQL. This parameter affects how timestamp with time zone is
    rendered in text encoding (but not binary), as well as some other
    time-related functions etc.

    If this parameter isn't set, the server's timezone is used, whatever that
    is. As long as the client and server happen to be in the same time zone
    that may be OK, but if not it seems extremely undesirable.

    Any comments?

    —
    Reply to this email directly or view it on GitHub
    #646.

    Regards,

    Francisco Figueiredo Jr.
    Npgsql Lead Developer
    http://www.npgsql.org
    http://gplus.to/franciscojunior
    http://fxjr.blogspot.com
    http://twitter.com/franciscojunior

  2. changed the title [-]Set timezone when opening connections?[/-] [+]Synchronize timezone with PostgreSQL[/+] on May 9, 2016
  3. roji commented on May 9, 2016

    @roji
    MemberAuthor

    The tricky problem here is to convert system time zone names (from Windows, Linux) to PostgreSQL, not sure how standard these are.

  4. roji commented on May 9, 2016

    @roji
    MemberAuthor

    This is going to be messy: PostgreSQL uses IANA/Olson, Windows uses... Windows (see http://stackoverflow.com/questions/5996320/net-timezoneinfo-from-olson-time-zone). We can include a translation table in PostgreSQL but it would become out of date... And then there's Linux/MacOS...

  5. roji commented on Jun 28, 2017

    @roji
    MemberAuthor

    Note that thanks to #1475 (in progress), we'll be able to add a Nodatime type mapping plugin #546. Since Nodatime has support for the different timezones and can apparently convert between them, it may be possible to implement this.

  6. roji commented on Jul 2, 2017

    @roji
    MemberAuthor

    Just to prevent my own confusion, this issue isn't about converting timestamptz values according to the PostgreSQL session timezone, it's about setting the PostgreSQL session timezone based on the local machine timezone.

  7. roji commented on Jul 7, 2017

    @roji
    MemberAuthor

    Am closing this in favor of #1634, which is about simply passing along what's in the PGTZ environment variable to PostgreSQL.

    Translating the Windows/.NET local system timezone to PostgreSQL is difficult for the reason mentioned above - translation of Windows timezones to Olson/IANA, which we can't really do reliably without adding a dependency on something like Nodatime.

    It's still possible for users to do this themselves - convert the local system timezone to Olson/IANA and have Npgsql send it etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions