You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// ignore previous timestamp transitions and use only the current system timestamp in local date and time so that the behavior is correct on Windows and Linux
820
-
final nowDt =DateTime.now();
821
-
var baseDt =DateTime(2000);
822
-
if (baseDt.timeZoneOffset != nowDt.timeZoneOffset) {
823
-
final difference = baseDt.timeZoneOffset - nowDt.timeZoneOffset;
824
-
baseDt = baseDt.add(difference);
825
-
}
812
+
813
+
final baseDt =_getPostgreSQLEpochBaseDate();
826
814
return baseDt.add(Duration(microseconds: value));
827
815
828
816
caseTypeOid.timestampWithTimezone:
@@ -1054,6 +1042,29 @@ class PostgresBinaryDecoder {
1054
1042
);
1055
1043
}
1056
1044
1045
+
/// Returns a base DateTime object representing the PostgreSQL epoch
1046
+
/// (January 1, 2000), adjusted to the current system's timezone offset.
1047
+
///
1048
+
/// This method ensures that the base DateTime object is consistent across
1049
+
/// different system environments (e.g., Windows, Linux) by adjusting the
1050
+
/// base DateTime's timezone offset to match the current system's timezone
1051
+
/// offset. This adjustment is necessary due to potential differences in
1052
+
/// how different operating systems handle timezone transitions.
1053
+
/// Returns:
1054
+
/// - A `DateTime` object representing January 1, 2000, adjusted to the
1055
+
/// current system's timezone offset.
1056
+
DateTime_getPostgreSQLEpochBaseDate() {
1057
+
// https://github.com/dart-lang/sdk/issues/56312
1058
+
// ignore past timestamp transitions and use only current timestamp in local datetime
1059
+
final nowDt =DateTime.now();
1060
+
var baseDt =DateTime(2000);
1061
+
if (baseDt.timeZoneOffset != nowDt.timeZoneOffset) {
1062
+
final difference = baseDt.timeZoneOffset - nowDt.timeZoneOffset;
1063
+
baseDt = baseDt.add(difference);
1064
+
}
1065
+
return baseDt;
1066
+
}
1067
+
1057
1068
List<V> readListBytes<V>(Uint8List data,
1058
1069
VFunction(ByteDataReader reader, int length) valueDecoder) {
0 commit comments