now.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include <stdio.h>
  6. #include <time.h>
  7. int main(int argc, char **argv)
  8. {
  9. #if defined(OMIT_LIB_BUILD_TIME)
  10. /*
  11. * Some platforms don't have any 64-bit integer type
  12. * such as 'long long'. Because we can't use NSPR's
  13. * PR_snprintf in this program, it is difficult to
  14. * print a static initializer for PRInt64 (a struct).
  15. * So we print nothing. The makefiles that build the
  16. * shared libraries will detect the empty output string
  17. * of this program and omit the library build time
  18. * in PRVersionDescription.
  19. */
  20. #elif defined(_MSC_VER)
  21. __int64 now;
  22. time_t sec;
  23. sec = time(NULL);
  24. now = (1000000i64) * sec;
  25. fprintf(stdout, "%I64d", now);
  26. #else
  27. long long now;
  28. time_t sec;
  29. sec = time(NULL);
  30. now = (1000000LL) * sec;
  31. fprintf(stdout, "%lld", now);
  32. #endif
  33. return 0;
  34. } /* main */
  35. /* now.c */