Reuse, not rework

License Awareness

Highly Reusable Software

By activity
Professions, Sciences, Humanities, Business, ...

User Interface
Text-based, GUI, Audio, Video, Keyboards, Mouse, Images,...

Text Strings
Conversions, tests, processing, manipulation,...

Integer, Floating point, Matrix, Statistics, Boolean, ...

Algorithms, Memory, Process control, Debugging, ...

Stored Data
Data storage, Integrity, Encryption, Compression, ...

Networks, protocols, Interprocess, Remote, Client Server, ...

Hard World
Timing, Calendar and Clock, Audio, Video, Printer, Controls...

File System
Management, Filtering, File & Directory access, Viewers, ...


librock_mkgmtime - calculate a time_t from a struct tm according to UTC.
#License - #Source code - #Example Use -


#include <librock/target/types.c>
#include <librock/datime.h>

    const librock_STRUCT_TM *tmptr,
    librock_TIME_T *ret


librock_mkgmtime() takes a pointer to a struct tm (cast to a librock_STRUCT_TM) with values in UTC, and returns a time_t, cast to librock_TIME_T. (The casts are part of the portability provided by librock/target/types.c, and normally they will be simply struct tm and time_t.)

This operates as ANSI mktime(), but interprets the members of struct tm according to UTC.

 tm_year is the year-1900.
 tm_mon is the month 0-11
 tm_mday is the day of month 1-31
 tm_hour is the hour 0-23
 tm_min is the minute 0-59
 tm_sec is the second 0-59.
 tm_isdst is ignored.

Typical use is to convert stored dates and times in UTC to a time_t.
For something that scans strings of GMT dates and times, see

#ifdef librock_TYPICAL_USE_mkgmtime
    #include <time.h>
    struct tm tmbuf;
    time_t t;
    tmbuf.tm_year = 2002-1900;
    tmbuf.tm_mon = 1;
    tmbuf.tm_mday = 2;
    tmbuf.tm_hour = 2;
    tmbuf.tm_min = 2;
    tmbuf.tm_sec = 2;
    tmbuf.tm_isdst = 0; /* Ignored */
    printf("%ld\n",(long) t);


 //No external calls.


  Copyright 1998-2002 Forrest J. Cavalier III,
  Licensed under BSD-ish license, NO WARRANTY. Copies must retain this block.
  License text in <librock/license/librock.txt> librock_LIDESC_HC=12440211096131f5976d36be0cddca4cd9152e45

Source Code

./hard/time/gmtime.c (implementation, plus source of this manual page)

This software is part of Librock

Rapid reuse, without rework. Details
This page copyright (C) 2002-2003 Forrest J. Cavalier III, d-b-a Mib Software, Saylorsburg PA 18353, USA

Verbatim copying and distribution of this generated page is permitted in any medium provided that no changes are made.
(The source of this manual page may be covered by a more permissive license which allows modifications.)

Want to help? We welcome comments, patches. -- Need help? Request paid support.