Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Jun 2009 23:12:58 +0200 (CEST)
From:      Wojciech Puchar <wojtek@wojtek.tensor.gdynia.pl>
To:        Polytropon <freebsd@edvax.de>
Cc:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Re: Date representation as YY/DDD or YYYY/DDD
Message-ID:  <alpine.BSF.2.00.0906032312330.27711@wojtek.tensor.gdynia.pl>
In-Reply-To: <20090603230314.bfeecf1a.freebsd@edvax.de>
References:  <20090603230314.bfeecf1a.freebsd@edvax.de>

next in thread | previous in thread | raw e-mail | index | archive | help
> 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 <stdio.h>
#include <time.h>
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.00.0906032312330.27711>