Back to index

courier  0.68.2
rfc1035fmttime.c
Go to the documentation of this file.
00001 /*
00002 ** Copyright 1998 - 2000 Double Precision, Inc.
00003 ** See COPYING for distribution information.
00004 */
00005 
00006 #include      "rfc1035.h"
00007 #include      <string.h>
00008 
00009 
00010 const char *rfc1035_fmttime(unsigned long n, char *buf)
00011 {
00012 unsigned long s,m,h;
00013 
00014        s = n % 60; n=n/60;
00015        m = n % 60; n=n/60;
00016        h = n % 24; n=n/24;
00017 
00018        buf[0]='\0';
00019        if (n) sprintf(buf,"%lud",n);
00020        if (n || h)   sprintf(buf+strlen(buf), "%luh", h);
00021        if (n || h || m)     sprintf(buf+strlen(buf), "%lum", m);
00022        sprintf(buf+strlen(buf), "%lus", s);
00023        return (buf);
00024 }