From owner-freebsd-questions Wed Mar 14 13:55:14 2001 Delivered-To: freebsd-questions@freebsd.org Received: from karon.dynas.se (karon.dynas.se [192.71.43.4]) by hub.freebsd.org (Postfix) with SMTP id 789DC37B71C for ; Wed, 14 Mar 2001 13:55:11 -0800 (PST) (envelope-from mikko@dynas.se) Received: (qmail 9654 invoked from network); 14 Mar 2001 21:55:09 -0000 Received: from spirit.sto.dynas.se (HELO spirit.dynas.se) (172.16.1.10) by 172.16.1.1 with SMTP; 14 Mar 2001 21:55:09 -0000 Received: (qmail 11179 invoked from network); 14 Mar 2001 21:55:07 -0000 Received: from explorer.rsa.com (10.81.217.59) by spirit.dynas.se with SMTP; 14 Mar 2001 21:55:07 -0000 Received: (from mikko@localhost) by explorer.rsa.com (8.11.1/8.11.1) id f2ELt4V10814; Wed, 14 Mar 2001 13:55:04 -0800 (PST) (envelope-from mikko) Date: Wed, 14 Mar 2001 13:55:04 -0800 (PST) From: Mikko Tyolajarvi Message-Id: <200103142155.f2ELt4V10814@explorer.rsa.com> To: ertank@softhome.net Cc: questions@freebsd.org Subject: Re: date time with C (off topic) Newsgroups: local.freebsd.questions References: <000701c0acc5$73eb9e50$5720fdd4@greenkey> X-Newsreader: NN version 6.5.6 (NOV) Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In local.freebsd.questions you write: >Hi, >I'm trying to write a little C program (not c++). I want to calculate the >next day. I have year, month and day values as integer as seperate >variables. I'm not talking about the day that program runs. It is a prior >date. I get it from a file. >I do not have good C knowledge. I thought I just can convert the date value >I have to seconds since 1.1.1970. After that I can add seconds for one day >to the converted date value. But, I couldn't do because I couldn't manage >how to calculate leap years. >How can I do that calculation correctly? Or, is there a simpler way to do >that? Or, a sample source code? Or something? See the mktime(3) man page. It is full of functions that can be used to do what you want, and will handle time zones, leap years, daylight savings time and whatnot. Maybe strftime(3) / strptime(3) can come handy too? /Mikko -- Mikko Työläjärvi_______________________________________mikko@rsasecurity.com RSA Security To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message