EpochTimeToString.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * 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. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. *
  9. */
  10. #include "FormatString.h"
  11. #include "EpochTimeToString.h"
  12. #include <stdio.h>
  13. #include <string.h>
  14. #include <stdarg.h>
  15. // localtime
  16. #include <time.h>
  17. #include "LinuxStrings.h"
  18. char * EpochTimeToString(long long time)
  19. {
  20. static int textIndex=0;
  21. static char text[4][64];
  22. if (++textIndex==4)
  23. textIndex=0;
  24. struct tm * timeinfo;
  25. time_t t = time;
  26. timeinfo = localtime ( &t );
  27. strftime (text[textIndex],64,"%c.",timeinfo);
  28. /*
  29. time_t
  30. // Copied from the docs
  31. struct tm *newtime;
  32. newtime = _localtime64(& time);
  33. asctime_s( text[textIndex], sizeof(text[textIndex]), newtime );
  34. while (text[textIndex][0] && (text[textIndex][strlen(text[textIndex])-1]=='\n' || text[textIndex][strlen(text[textIndex])-1]=='\r'))
  35. text[textIndex][strlen(text[textIndex])-1]=0;
  36. */
  37. return text[textIndex];
  38. }
粤ICP备19079148号