File: mktime.c

package info (click to toggle)
libconvert-binary-c-perl 0.86-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,264 kB
  • sloc: ansic: 47,836; perl: 4,980; yacc: 2,143; makefile: 61
file content (53 lines) | stat: -rw-r--r-- 970 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* mktime( struct tm * )

   This file is part of the Public Domain C Library (PDCLib).
   Permission is granted to use, modify, and / or redistribute at will.
*/

#include <time.h>

#ifndef REGTEST

#include "pdclib/_PDCLIB_tzcode.h"

#ifndef __STDC_NO_THREADS__
#include <threads.h>
extern mtx_t _PDCLIB_time_mtx;
#endif

time_t mktime( struct tm * timeptr )
{
    time_t t;
    _PDCLIB_LOCK( _PDCLIB_time_mtx );
    _PDCLIB_tzset_unlocked();
    t = _PDCLIB_mktime_tzname( &_PDCLIB_lclmem, timeptr, true );
    _PDCLIB_UNLOCK( _PDCLIB_time_mtx );
    return t;
}

#endif

#ifdef TEST

#include "_PDCLIB_test.h"

#include <limits.h>

int main( void )
{
    /* System Clock DST */
    struct tm time;
    time_t t;

    MKTIME( time, 52, 45, 21, 13, 11, 1, 0, 0 );
    t = mktime( &time );
    TESTCASE( t == -2147483648l );

    MKTIME( time, 7, 14, 4, 19, 0, 138, 0, 0 );
    t = mktime( &time );
    TESTCASE( t == 2147483647l );

    return TEST_RESULTS;
}

#endif