Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jens Gustedt
P99 - macros and functions for C99
Commits
3a28b2f3
Commit
3a28b2f3
authored
Oct 27, 2013
by
Jens Gustedt
Browse files
add test for the detection of the DST time difference
parent
053e9cc9
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/test-p99-c11.c
View file @
3a28b2f3
...
...
@@ -2,7 +2,7 @@
/* */
/* Except for parts copied from previous work and as explicitly stated below, */
/* the author and copyright holder for this work is */
/* all rights reserved, 2011-201
2
Jens Gustedt, INRIA, France */
/* all rights reserved, 2011-201
3
Jens Gustedt, INRIA, France */
/* */
/* This file is free software; it is part of the P99 project. */
/* You can redistribute it and/or modify it under the terms of the QPL as */
...
...
@@ -132,6 +132,31 @@ int main(int argc, char* argv[]) {
mktime
(
&
tm
);
asctime_s
(
date
,
sizeof
date
,
&
tm
);
printf
(
"no leap year:
\t
%s"
,
date
);
localtime_s
(
&
now
,
&
tm
);
tm
.
tm_mon
=
0
;
tm
.
tm_mday
=
1
;
tm
.
tm_isdst
=
-
1
;
time_t
jan1
=
mktime
(
&
tm
);
if
(
tm
.
tm_isdst
>
0
)
{
tm
.
tm_mon
=
0
;
tm
.
tm_mday
=
1
;
tm
.
tm_isdst
=
0
;
time_t
jan1_dst
=
mktime
(
&
tm
);
printf
(
"DST difference on Jan 1, %u: %g minutes
\n
"
,
(
tm
.
tm_year
+
1900
),
difftime
(
jan1_dst
,
jan1
)
/
60
.
0
);
}
tm
.
tm_mon
=
6
;
tm
.
tm_mday
=
1
;
tm
.
tm_isdst
=
-
1
;
time_t
jul1
=
mktime
(
&
tm
);
if
(
tm
.
tm_isdst
>
0
)
{
tm
.
tm_mon
=
6
;
tm
.
tm_mday
=
1
;
tm
.
tm_isdst
=
0
;
time_t
jul1_dst
=
mktime
(
&
tm
);
printf
(
"DST difference on Jul 1, %u: %g minutes
\n
"
,
(
tm
.
tm_year
+
1900
),
difftime
(
jul1_dst
,
jul1
)
/
60
.
0
);
}
print_attribute
(
deprecated
);
print_attribute
(
weak
);
print_attribute
(
weakref
);
...
...
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