-
Notifications
You must be signed in to change notification settings - Fork 0
/
datestr.c
61 lines (55 loc) · 1.87 KB
/
datestr.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <stdio.h>
#include "romcal.h"
char *datestr(int doy,
int year)
{
/*----------------------------------------------------------------------*
*
* @(#)ROMCAL datestr.c 6.1 02/12/06 17:23:55
*
* Copyright (C) 1993,1995,1999 Kenneth G. Bath
* Permission to use and modify this software and its
* documentation for any purpose other than its incorporation
* into a commercial product is hereby granted without fee.
*
* Permission to copy and distribute this software and its
* documentation only for non-commercial use is also granted
* without fee, provided, however, that the above copyright
* notice appear in all copies, that both that copyright
* notice and this permission notice appear in supporting
* documentation. The author makes no representations about
* the suitability of this software for any purpose. It is
* provided "as is" without express or implied warranty.
*
*-------------------- Software Unit Description -----------------------*
*
* This module will return a pointer to a character string of
* a date given the day of year and year.
*
*---------------------- Software Unit History -------------------------*
*
* 14Mar93 : created, kgb
* 08Feb02 : recoded to use doydate, kgb
*
*----------------------------------------------------------------------*/
static char *montab[] =
{
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
int imon,
iday;
static char retval[40];
/*----------------------------------------------------------------------*
* begin code *
*----------------------------------------------------------------------*/
/*
* Convert the day of the year to month/day.
*/
doydate(year, doy, &imon, &iday);
/*
* Form a string with the month, day, and year.
*/
sprintf(retval, "%s %2d, %d", montab[imon-1], iday, year);
return (&retval[0]);
}