File: localtime_r.cpp

package info (click to toggle)
vdr-plugin-markad 4.2.15-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,084 kB
  • sloc: cpp: 22,441; python: 613; makefile: 270; sh: 95
file content (28 lines) | stat: -rw-r--r-- 611 bytes parent folder | download | duplicates (3)
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
#include "localtime_r.h"

#if __cplusplus <= CPLUSPLUS_20
#include <time.h>
#include <errno.h>
#include "../global.h"

#if defined (WINDOWS)
struct tm* localtime_r(const time_t* timer, struct tm* buf) {

  /* NOTE: careful here!
   *
   * MSDN :  errno_t    localtime_s(struct tm* const tmDest, time_t const* const sourceTime);
   * C++11:  struct tm* localtime_s(const time_t* restrict timer, struct tm* restrict buf);
   */

  // cppcheck-suppress AssignmentAddressToInteger
  errno_t r = localtime_s(buf, timer);

  if (r != 0)
     errno = EINVAL;
  else
     errno = 0;
     
  return buf;
}
#endif
#endif