1 /*
2  * Copyright (c) 2017, NVIDIA CORPORATION.  All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 /* clang-format off */
19 
20 /*	fdate3f.c - Implements LIB3F fdate subprogram.  */
21 
22 #include "ent3f.h"
23 
24 #include <time.h>
25 #include "utils3f.h"
26 
27 #if !defined(WIN32) && !defined(WIN64)
28 WIN_MSVCRT_IMP char *WIN_CDECL ctime(const time_t *);
29 #endif
30 
ENT3F(FDATE,fdate)31 void ENT3F(FDATE, fdate)(DCHAR(str) DCLEN(str))
32 {
33   char *str = CADR(str);
34   int len = CLEN(str);
35   time_t t;
36   char *p;
37   int i;
38 
39   t = time(0);
40   p = ctime(&t);
41   __fcp_cstr(str, len, p);
42   for (i = len - 1; i >= 0; i--)
43     if (str[i] == '\n') {
44       str[i] = ' ';
45       break;
46     }
47 
48   return;
49 }
50