Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
d1b2260c
Commit
d1b2260c
authored
Sep 01, 2004
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add code to be able to match the timezone name on localized Windows
systems. Magnus Hagander.
parent
0b143dd7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
108 additions
and
1 deletion
+108
-1
src/timezone/pgtz.c
src/timezone/pgtz.c
+108
-1
No files found.
src/timezone/pgtz.c
View file @
d1b2260c
...
...
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.2
4 2004/08/30 02:54:42 momjian
Exp $
* $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.2
5 2004/09/01 16:21:50 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -822,8 +822,11 @@ identify_system_timezone(void)
{
int
i
;
char
tzname
[
128
];
char
localtzname
[
256
];
time_t
t
=
time
(
NULL
);
struct
tm
*
tm
=
localtime
(
&
t
);
HKEY
rootKey
;
int
idx
;
if
(
!
tm
)
{
...
...
@@ -846,6 +849,110 @@ identify_system_timezone(void)
}
}
/*
* Localized Windows versions return localized names for the
* timezone. Scan the registry to find the English name,
* and then try matching against our table again.
*/
memset
(
localtzname
,
0
,
sizeof
(
localtzname
));
if
(
RegOpenKeyEx
(
HKEY_LOCAL_MACHINE
,
"SOFTWARE
\\
Microsoft
\\
Windows NT
\\
CurrentVersion
\\
Time Zones"
,
0
,
KEY_READ
,
&
rootKey
)
!=
ERROR_SUCCESS
)
{
ereport
(
WARNING
,
(
errmsg_internal
(
"could not open registry key to identify Windows timezone: %i"
,
(
int
)
GetLastError
())));
return
NULL
;
}
for
(
idx
=
0
;
;
idx
++
)
{
char
keyname
[
256
];
char
zonename
[
256
];
DWORD
namesize
;
FILETIME
lastwrite
;
HKEY
key
;
LONG
r
;
memset
(
keyname
,
0
,
sizeof
(
keyname
));
namesize
=
sizeof
(
keyname
);
if
((
r
=
RegEnumKeyEx
(
rootKey
,
idx
,
keyname
,
&
namesize
,
NULL
,
NULL
,
NULL
,
&
lastwrite
))
!=
ERROR_SUCCESS
)
{
if
(
r
==
ERROR_NO_MORE_ITEMS
)
break
;
ereport
(
WARNING
,
(
errmsg_internal
(
"could not enumerate registry subkeys to identify Windows timezone: %i"
,
(
int
)
r
)));
break
;
}
if
((
r
=
RegOpenKeyEx
(
rootKey
,
keyname
,
0
,
KEY_READ
,
&
key
))
!=
ERROR_SUCCESS
)
{
ereport
(
WARNING
,
(
errmsg_internal
(
"could not open registry subkey to identify Windows timezone: %i"
,
(
int
)
r
)));
break
;
}
memset
(
zonename
,
0
,
sizeof
(
zonename
));
namesize
=
sizeof
(
zonename
);
if
((
r
=
RegQueryValueEx
(
key
,
"Std"
,
NULL
,
NULL
,
zonename
,
&
namesize
))
!=
ERROR_SUCCESS
)
{
ereport
(
WARNING
,
(
errmsg_internal
(
"could not query value for 'std' to identify Windows timezone: %i"
,
(
int
)
r
)));
RegCloseKey
(
key
);
break
;
}
if
(
strcmp
(
tzname
,
zonename
)
==
0
)
{
/* Matched zone */
strcpy
(
localtzname
,
keyname
);
RegCloseKey
(
key
);
break
;
}
memset
(
zonename
,
0
,
sizeof
(
zonename
));
namesize
=
sizeof
(
zonename
);
if
((
r
=
RegQueryValueEx
(
key
,
"Dlt"
,
NULL
,
NULL
,
zonename
,
&
namesize
))
!=
ERROR_SUCCESS
)
{
ereport
(
WARNING
,
(
errmsg_internal
(
"could not query value for 'dlt' to identify Windows timezone: %i"
,
(
int
)
r
)));
RegCloseKey
(
key
);
break
;
}
if
(
strcmp
(
tzname
,
zonename
)
==
0
)
{
/* Matched DST zone */
strcpy
(
localtzname
,
keyname
);
RegCloseKey
(
key
);
break
;
}
RegCloseKey
(
key
);
}
RegCloseKey
(
rootKey
);
if
(
localtzname
[
0
])
{
/* Found a localized name, so scan for that one too */
for
(
i
=
0
;
win32_tzmap
[
i
].
stdname
!=
NULL
;
i
++
)
{
if
(
strcmp
(
localtzname
,
win32_tzmap
[
i
].
stdname
)
==
0
||
strcmp
(
localtzname
,
win32_tzmap
[
i
].
dstname
)
==
0
)
{
elog
(
DEBUG4
,
"TZ
\"
%s
\"
matches localized Windows timezone
\"
%s
\"
(
\"
%s
\"
)"
,
win32_tzmap
[
i
].
pgtzname
,
tzname
,
localtzname
);
return
win32_tzmap
[
i
].
pgtzname
;
}
}
}
ereport
(
WARNING
,
(
errmsg
(
"could not find a match for Windows timezone
\"
%s
\"
"
,
tzname
)));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment