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 /* unpacktimeqq3f.c - Implements DFLIB packtimeqq subprogram. */
21 #if defined(WIN64) || defined(WIN32)
22 #include <windows.h>
23 #endif
24 #include <string.h>
25 #include <stdlib.h>
26 #include "mpalloc.h"
27 /* must include ent3f.h AFTER io3f.h */
28 #include "io3f.h"
29 #include "ent3f.h"
30
31 #if defined(WIN64) || defined(WIN32)
32 extern char *__fstr2cstr();
33 extern void __UnpackTime(unsigned int secsSince1970, ULARGE_INTEGER *fileTime);
34
ENT3F(UNPACKTIMEQQ,unpacktimeqq)35 void ENT3F(UNPACKTIMEQQ, unpacktimeqq)(unsigned int *timedate, int *year,
36 int *month, int *day, int *hour,
37 int *minute, int *second)
38 {
39 SYSTEMTIME *sysTime;
40 FILETIME *fileTime;
41 ULARGE_INTEGER quadTime;
42
43 fileTime = (FILETIME *)_mp_malloc(sizeof(FILETIME));
44 sysTime = (SYSTEMTIME *)_mp_malloc(sizeof(SYSTEMTIME));
45 __UnpackTime(*timedate, &quadTime);
46 fileTime->dwLowDateTime = quadTime.u.LowPart;
47 fileTime->dwHighDateTime = quadTime.u.HighPart;
48 FileTimeToSystemTime(fileTime, sysTime);
49
50 *year = sysTime->wYear;
51 *month = sysTime->wMonth;
52 *day = sysTime->wDay;
53 *hour = sysTime->wHour;
54 *minute = sysTime->wMinute;
55 *second = sysTime->wSecond;
56
57 _mp_free(fileTime);
58 _mp_free(sysTime);
59 }
60 #else
ENT3F(UNPACKTIMEQQ,unpacktimeqq)61 void ENT3F(UNPACKTIMEQQ, unpacktimeqq)(int *timedate, int *year, int *month,
62 int *day, int *hour, int *minute,
63 int *second)
64 {
65 fprintf(__io_stderr(), "unpacktimeqq() not implemented on this target\n");
66 }
67
68 #endif
69