repo: shell-daemons
action: blob
revision: 
path_from: rfc7231date.c
revision_from: refs/heads/master:
path_to: 
revision_to: 
git.thebackupbox.net
shell-daemons
git clone git://git.thebackupbox.net/shell-daemons

blob of:

shell-daemons

/ rfc7231date.c

blob_plain of this file

refs/heads/master:/rfc7231date.c

 #include 
 #include 
 #include 
 #include 

 int main(int argc,char *argv[]) {
   const struct tm *tm;
   time_t t;
   char ts[256];
   if(argc > 1) {
     if(argv[1][0] == '+') {//relatives start with +
       t=time(0)+atoi(argv[1]+1);
     } else {//otherwise absolute value
       t=atoi(argv[1]);
     }
   } else {
    t=time(0);
   }
   tm=gmtime(&t);
   strftime(ts,256,"%a, %d %b %Y %H:%M:%S %Z\n",tm);
   write(1,ts,strlen(ts));
 }