SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EpochTimeToString.cpp
Go to the documentation of this file.
1 /*
2 * Original work: Copyright (c) 2014, Oculus VR, Inc.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD-style license found in the
6 * RakNet License.txt file in the licenses directory of this source tree. An additional grant
7 * of patent rights can be found in the RakNet Patents.txt file in the same directory.
8 *
9 *
10 * Modified work: Copyright (c) 2016-2017, SLikeSoft UG (haftungsbeschränkt)
11 *
12 * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
13 * license found in the license.txt file in the root directory of this source tree.
14 */
15
16 #include "slikenet/FormatString.h"
17 #include "slikenet/EpochTimeToString.h"
18 #include <stdio.h>
19 #include <string.h>
20 #include <stdarg.h>
21 // localtime
22 #include <time.h>
23 #include "slikenet/LinuxStrings.h"
24 #include "slikenet/linux_adapter.h"
25 #include "slikenet/osx_adapter.h"
26
27 char * EpochTimeToString(long long time)
28 {
29 static int textIndex=0;
30 static char text[4][64];
31
32 if (++textIndex==4)
33 textIndex=0;
34
35 struct tm timeinfo;
36 time_t t = time;
37 localtime_s ( &timeinfo, &t );
38 strftime (text[textIndex],64,"%c.",&timeinfo);
39
40 /*
41 time_t
42 // Copied from the docs
43 struct tm *newtime;
44 newtime = _localtime64(& time);
45 asctime_s( text[textIndex], sizeof(text[textIndex]), newtime );
46
47 while (text[textIndex][0] && (text[textIndex][strlen(text[textIndex])-1]=='\n' || text[textIndex][strlen(text[textIndex])-1]=='\r'))
48 text[textIndex][strlen(text[textIndex])-1]=0;
49 */
50
51 return text[textIndex];
52 }