From owner-freebsd-questions@FreeBSD.ORG Wed Jun 3 21:13:08 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 70E8310656ED for ; Wed, 3 Jun 2009 21:13:08 +0000 (UTC) (envelope-from wojtek@wojtek.tensor.gdynia.pl) Received: from wojtek.tensor.gdynia.pl (wojtek.tensor.gdynia.pl [IPv6:2001:4070:101:2::1]) by mx1.freebsd.org (Postfix) with ESMTP id AE53D8FC08 for ; Wed, 3 Jun 2009 21:13:07 +0000 (UTC) (envelope-from wojtek@wojtek.tensor.gdynia.pl) Received: from wojtek.tensor.gdynia.pl (localhost [IPv6:::1]) by wojtek.tensor.gdynia.pl (8.14.3/8.14.3) with ESMTP id n53LCwLp027866; Wed, 3 Jun 2009 23:12:58 +0200 (CEST) (envelope-from wojtek@wojtek.tensor.gdynia.pl) Received: from localhost (wojtek@localhost) by wojtek.tensor.gdynia.pl (8.14.3/8.14.3/Submit) with ESMTP id n53LCwCm027863; Wed, 3 Jun 2009 23:12:58 +0200 (CEST) (envelope-from wojtek@wojtek.tensor.gdynia.pl) Date: Wed, 3 Jun 2009 23:12:58 +0200 (CEST) From: Wojciech Puchar To: Polytropon In-Reply-To: <20090603230314.bfeecf1a.freebsd@edvax.de> Message-ID: References: <20090603230314.bfeecf1a.freebsd@edvax.de> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: FreeBSD Questions Subject: Re: Date representation as YY/DDD or YYYY/DDD X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jun 2009 21:13:09 -0000 > as 2009-01-01 would be 09/001, 2009-02-01 would be 2009/032. > > I've read "man date" and "man strftime", and it didn't look > like this is already built in. > > What am I missing? > > If it's not invented yet, I'll do this on my own, but maybe > I don't need to re-invent the wheel. :-) > #include #include main(int argc,char **argv) { time_t tmp1=time(0); struct tm tmp2; localtime_r(&tmp1,&tmp2); if(argc>1) printf("%02d",(tmp2.tm_year/100)+19); printf("%02d/%03d\n",tmp2.tm_year%100,tmp2.tm_yday+1); return 0; }; started with no arguments gives YY/DDD, with any argument - YYYY/DDD