Thomas,

(or anybody on Mac OS X)

On 05/03/2014 08:40 PM, Markus Wanner wrote:
> I'll try to see what I can do with such a crippled mktime().

Can you please try the attached simple test program?

  $ g++ -o test test.cc
  $ ./test

Regards

Markus Wanner

#include <iostream>
#include <fstream>
#include <cstdlib>
#include <ctime>

int main() {
  if (sizeof(struct tm) <= 4)
	{
	  std::cout << "sizeof(struct tm) == 4\n";
	  return EXIT_SUCCESS;
	}

  /* just in the range of 32-bit */
  int64_t exp_result = 2147483647LL;
  struct tm tb = { 7, 14, 4, 19, 0, 138, 0, 0, -1 };

  int64_t t = std::mktime(&tb);
  if (t != exp_result)
	{
	  std::cout << "wrong result for 32-bit time (off by "
				<< (exp_result - std::mktime(&tb)) << ")\n";
	  return EXIT_FAILURE;
	}

  /* not in range, anymore, needs proper 64-bit processing */
  tb.tm_sec += 1;
  exp_result += 1;
  t = std::mktime(&tb);
  if (t == -1)
	{
	  std::cout << "crippled mktime detected (got -1)\n";
	  return EXIT_FAILURE;
	}
  else if (t != exp_result)
	{
	  std::cout << "wrong result for 64-bit time (off by "
				<< (exp_result - std::mktime(&tb)) << ")\n";
	  return EXIT_FAILURE;
	}
  else
	{
	  std::cout << "mktime seems okay" << std::endl;
	  return EXIT_SUCCESS;
	}
}
_______________________________________________
Monotone-devel mailing list
Monotone-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/monotone-devel

Reply via email to