Date: Wed, 14 Mar 2001 13:55:04 -0800 (PST) From: Mikko Tyolajarvi <mikko@dynas.se> To: ertank@softhome.net Cc: questions@freebsd.org Subject: Re: date time with C (off topic) Message-ID: <200103142155.f2ELt4V10814@explorer.rsa.com> References: <000701c0acc5$73eb9e50$5720fdd4@greenkey>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200103142155.f2ELt4V10814>