Date: Mon, 5 Oct 1998 07:00:00 -0700 (PDT) From: Q <q@fan.net.au> To: freebsd-bugs@FreeBSD.ORG Subject: Re: misc/8156: mktime does not set tm_wday Message-ID: <199810051400.HAA06697@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR misc/8156; it has been noted by GNATS.
From: Q <q@fan.net.au>
To: estartu@augusta.de
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: misc/8156: mktime does not set tm_wday
Date: Mon, 5 Oct 1998 23:49:48 +1000 (EST)
On Mon, 5 Oct 1998 estartu@augusta.de wrote:
> >Originator: Gerhard Schmidt
> >Organization:
> Augsburger Computer Forum e.V.
> >Release: 2.2.7-stable
> >Environment:
> FreeBSD inga.augusta.de 2.2.7-STABLE FreeBSD 2.2.7-STABLE #0: Thu Sep 17 15:22:59 MET DST 1998 root@inga.augusta.de:/usr/src/sys/compile/INGA i386
>
> >Description:
> I have to finde out the weeekday of a spezific date and tryed to do
> this using mktime. As Said in the Manpage tm_wday is set to the weekday
> the programm fills the struct tm with the date and calles mktime
> but after return tm_wday hasn't change.
> >How-To-Repeat:
> struct tm Z
> Z->tm_mday = 1;
> Z->tm_mon = 1;
> Z->tm_year = 1999;
> Z->tm_isdst = -1;
> mktime(&Z);
>
> >Fix:
From mktime() man page:
External declarations as well as the tm structure definition are in the
<time.h> include file. The tm structure includes at least the
following fields:
int tm_sec; /* seconds (0 - 60) */
int tm_min; /* minutes (0 - 59) */
int tm_hour; /* hours (0 - 23) */
int tm_mday; /* day of month (1 - 31) */
int tm_mon; /* month of year (0 - 11) */
int tm_year; /* year - 1900 */
^^^^^^^^^^^
It's not a bug. Your using the struct incorrectly. Every call you make to
mktime() will be returning -1. You are effectively asking it for the year
3899. Which can't be expresses using a time_t value. Change 'tm_year =
1999' to 'tm_year = 99'. You should put your Y2K hat on if you plan to use
a 'struct tm' in your application.
Seeya...Q
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
_____ / Quinton Dolan - q@fan.net.au
__ __/ / / __/ / / Systems Administrator
/ __ / _/ / / Fast Access Network
__/ __/ __/ ____/ / - / Gold Coast, QLD, Australia
_______ / Ph: +61 7 5574 1050
\_\ SAGE-AU Member
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199810051400.HAA06697>
