From owner-freebsd-questions@FreeBSD.ORG Tue Aug 10 17:13:01 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6883216A4CE for ; Tue, 10 Aug 2004 17:13:01 +0000 (GMT) Received: from aiolos.otenet.gr (aiolos.otenet.gr [195.170.0.23]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7983D43D39 for ; Tue, 10 Aug 2004 17:13:00 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from orion.daedalusnetworks.priv (aris.bedc.ondsl.gr [62.103.39.226])i7AHCwDa003168; Tue, 10 Aug 2004 20:12:58 +0300 Received: from orion.daedalusnetworks.priv (orion [127.0.0.1]) i7AHCuIJ026499; Tue, 10 Aug 2004 20:12:56 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost)i7AHCugv026498; Tue, 10 Aug 2004 20:12:56 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Tue, 10 Aug 2004 20:12:56 +0300 From: Giorgos Keramidas To: Mipam Message-ID: <20040810171256.GA26475@orion.daedalusnetworks.priv> References: <20040810162612.GC25389@orion.daedalusnetworks.priv> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: cc: freebsd-questions@freebsd.org Subject: Re: localtime question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2004 17:13:01 -0000 On 2004-08-10 18:45, Mipam wrote: > #include > #include > > int main(void) > { > struct timeval tv; > struct timeval tv_current; > if (gettimeofday(&tv_current, NULL) == -1) > err(1, "Could not get local time of day"); > tv.tv_sec = tv_current.tv_sec-86400; > printf("%s\n", ctime(&tv.tv_sec)); > return 0; > } Hmmm, now that I noticed. You don't need to add a trailing '\n' to the string of ctime(). It already has one: keramida@orion[20:11]/home/keramida$ ./a.out Mon Aug 9 20:11:30 2004 keramida@orion[20:11]/home/keramida$ Bye