OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uC-libc/] [time/] [asc_conv.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
 
2
#include <time.h>
3
#include <string.h>
4
/*
5
 * Internal ascii conversion routine, avoid use of printf, it's a bit big!
6
 */
7
 
8
 
9
static void
10
hit(buf, val)
11
char * buf;
12
int val;
13
{
14
   *buf = '0' + val%10;
15
}
16
 
17
void
18
__asctime(buffer, ptm)
19
register char * buffer;
20
struct tm * ptm;
21
{
22
static char days[] = "SunMonTueWedThuFriSat";
23
static char mons[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
24
   int year;
25
 
26
   /*              012345678901234567890123456 */
27
   strcpy(buffer, "Err Err .. ..:..:.. ....\n");
28
   if( (ptm->tm_wday >= 0) && (ptm->tm_wday <= 6) )
29
     memcpy(buffer, days+3*(ptm->tm_wday), 3);
30
 
31
   if( (ptm->tm_mon >= 0) && (ptm->tm_mon <= 11) )
32
     memcpy(buffer+4, mons+3*(ptm->tm_mon), 3);
33
 
34
 
35
   hit(buffer+ 8, ptm->tm_mday/10);
36
   hit(buffer+ 9, ptm->tm_mday   );
37
   hit(buffer+11, ptm->tm_hour/10);
38
   hit(buffer+12, ptm->tm_hour   );
39
   hit(buffer+14, ptm->tm_min/10);
40
   hit(buffer+15, ptm->tm_min   );
41
   hit(buffer+17, ptm->tm_sec/10);
42
   hit(buffer+18, ptm->tm_sec   );
43
 
44
   year = ptm->tm_year + 1900;
45
   hit(buffer+20, year/1000);
46
   hit(buffer+21, year/100);
47
   hit(buffer+22, year/10);
48
   hit(buffer+23, year);
49
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.