File: grdate.c

package info (click to toggle)
pgplot5 5.2.2-19.7
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid, trixie
  • size: 7,188 kB
  • sloc: fortran: 39,795; ansic: 22,554; objc: 1,534; sh: 1,298; makefile: 267; pascal: 233; perl: 209; tcl: 190; awk: 51; csh: 25
file content (70 lines) | stat: -rw-r--r-- 1,821 bytes parent folder | download | duplicates (15)
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
62
63
64
65
66
67
68
69
70
#include <time.h>
#include <string.h>

#ifdef PG_PPU
#define GRDATE grdate_
#else
#define GRDATE grdate
#endif

/**GRDATE -- get date and time as character string (Cray)
 *+
 *    SUBROUTINE GRDATE(STRING, L)
 *    CHARACTER*(*) STRING
 *     INTEGER L
 *
 * Return the current date and time, in format 'dd-Mmm-yyyy hh:mm'.
 * To receive the whole string, the STRING should be declared
 * CHARACTER*17.
 *
 * Arguments:
 *  STRING : receives date and time, truncated or extended with
 *           blanks as necessary.
 *  SLEN   : receives the number of characters in STRING, excluding
 *           trailing blanks. This will always be 17, unless the length
 *           of the string supplied is shorter.
 *--
 * 09-Nov-1994 - [mcs] Fortran callable C version for CRAY.
 *-----------------------------------------------------------------------
 */
void GRDATE(string, slen, maxlen)
     char *string; int *slen; int maxlen;
{
  char vtime[18];  /* Output string compilation buffer */
  char *utime;     /* Returned string from ctime() */
  time_t x;        /* Time returned by time() */
  int i;
/*
 * Get the standard C time string.
 */
  time(&x);
  utime = ctime(&x);
/*
 * Copy a re-organised version of the time string into vtime[].
 */
  vtime[0] = utime[8];
  vtime[1] = utime[9];
  vtime[2] = '-';
  vtime[3] = utime[4];
  vtime[4] = utime[5];
  vtime[5] = utime[6];
  vtime[6] = '-';
  vtime[7] = utime[20];
  vtime[8] = utime[21];
  vtime[9] = utime[22];
  vtime[10] = utime[23];
  vtime[11] = ' ';
  strncpy(vtime+12, utime+11, 5);
  vtime[17]='\0';
/*
 * Copy up to maxlen characters of vtime into the output FORTRAN string.
 */
  strncpy(string, vtime, maxlen);
  *slen = (maxlen < 17) ? maxlen : 17;
/*
 * Pad the FORTRAN string with spaces.
 */
  for(i=17; i<maxlen; i++)
    string[i] = ' ';
  return;
}