Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
734f1b38
...
734f1b388734becb310f15ca461740cbcb09a67a
authored
2013-04-02 17:12:47 +0300
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Rewrite mu_utc_offset in a more portable (hopefully) way.
1 parent
933bc7a2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
libmailutils/datetime/utcoff.c
libmailutils/datetime/utcoff.c
View file @
734f1b3
...
...
@@ -20,10 +20,17 @@
#endif
#include <time.h>
#define TMSEC(t) (((t)->tm_hour * 60 + (t)->tm_min) * 60 + (t)->tm_sec)
/* Returns the offset of our timezone from UTC, in seconds. */
int
mu_utc_offset
(
void
)
{
tzset
();
return
-
timezone
;
time_t
t
=
time
(
NULL
);
struct
tm
ltm
=
*
localtime
(
&
t
);
struct
tm
gtm
=
*
gmtime
(
&
t
);
int
d
=
TMSEC
(
&
ltm
)
-
TMSEC
(
&
gtm
);
if
(
!
(
ltm
.
tm_year
=
gtm
.
tm_year
&&
ltm
.
tm_mon
==
gtm
.
tm_mon
))
d
+=
86400
;
return
d
;
}
...
...
Please
register
or
sign in
to post a comment