-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
decode timestamp without timezone as local DateTime and decode timestamp with timezone respecting the timezone defined in the connection #342
Open
insinfo
wants to merge
6
commits into
isoos:master
Choose a base branch
from
insinfo:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
901c5c7
decode timestamp without timezone as local DateTime and decode timest…
485351f
add more flexibility on how timestamp and timestaptz types are decode…
0b1e037
add more flexibility on how timestamp and timestaptz types are decode…
558f2ef
fix define location for TZDateTime.toLocal()
ab75ea7
fix decode timestamp without timezone as local DateTime, ignore past …
f239799
extract method to create a PostgreSQL Epoch Base DateTime using the c…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,4 +83,4 @@ void main() async { | |
print(await subscription.schema); | ||
|
||
await conn.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/// A class to configure time zone settings for decoding timestamps and dates. | ||
class TimeZoneSettings { | ||
/// The default time zone value. | ||
/// | ||
/// The [value] represents the name of the time zone location. Default is 'UTC'. | ||
String value = 'UTC'; | ||
|
||
/// Creates a new instance of [TimeZoneSettings]. | ||
/// | ||
/// [value] is the name of the time zone location. | ||
/// | ||
/// The optional named parameters: | ||
/// - [forceDecodeTimestamptzAsUTC]: if true, decodes timestamps with timezone (timestamptz) as UTC. If false, decodes them using the timezone defined in the connection. | ||
/// - [forceDecodeTimestampAsUTC]: if true, decodes timestamps without timezone (timestamp) as UTC. If false, decodes them as local datetime. | ||
/// - [forceDecodeDateAsUTC]: if true, decodes dates as UTC. If false, decodes them as local datetime. | ||
TimeZoneSettings( | ||
this.value, { | ||
this.forceDecodeTimestamptzAsUTC = true, | ||
this.forceDecodeTimestampAsUTC = true, | ||
this.forceDecodeDateAsUTC = true, | ||
}); | ||
|
||
/// If true, decodes the timestamp with timezone (timestamptz) as UTC. | ||
/// If false, decodes the timestamp with timezone using the timezone defined in the connection. | ||
bool forceDecodeTimestamptzAsUTC = true; | ||
|
||
/// If true, decodes the timestamp without timezone (timestamp) as UTC. | ||
/// If false, decodes the timestamp without timezone as local datetime. | ||
bool forceDecodeTimestampAsUTC = true; | ||
|
||
/// If true, decodes the date as UTC. | ||
/// If false, decodes the date as local datetime. | ||
bool forceDecodeDateAsUTC = true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not update the
timeZone
value like this, it is a bit unexpected here. Thev3/connection.dart
_handleMessage
already stores it inPgConnectionImplementation._parameters
and we should just read that value from there. I think the settings should be immutable (maybe renameTimeZoneSettings.value
intodefaultTimeZone
), and use the server-provided timeZone if present, otherwise the fallback.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that in this case it should not be immutable because when you use the SQL command "set timezone TO 'GMT';" you are changing the connection configuration, and this has to be reflected in the connection instance, because if after the user executes the SQL command to change the timezone and he reads the timezone property he will want to see the current value, right? I don't know the driver code very well, especially version 3, so I don't know if the driver user can read the timezone of the current connection through some method or property, as I have been very busy I haven't had much time to look at this, I don't know exactly how this could be done in another way.