<commit_before>/*
 * Copyright (c) 2007-2010 Digital Bazaar, Inc. All rights reserved.
 */
#ifndef monarch_rt_TimeFunctions_H
#define monarch_rt_TimeFunctions_H

/**
 * This header provides some cross-platform definitions for time functions.
 *
 * Primarily, this header defines functionality for missing POSIX time
 * functions in windows.
 *
 * FIXME: This header's code should be relocated to .c/.cpp.
 *
 * @author <NAME>
 */

// include types, time, and errno
#include <sys/types.h>
#include <sys/time.h>
#include <errno.h>
#include <sys/timeb.h>
#include <inttypes.h>

//// prevent C++ name mangling
//#ifdef __cplusplus
//extern "C" {
//#endif

/**
 * Gets the number of minutes west of GMT the current time zone is.
 *
 * @return the number of minutes west of GMT the current time zone is.
 */
inline static int64_t gGetTimeZoneMinutesWest()
{
   struct timeb time;
   ftime(&time);

   // apply daylight savings time
   if(time.dstflag != 0)
   {
      time.timezone -= 60;
   }

   return time.timezone;
}

#ifdef WIN32

// define time between the epoch (01/01/1970) and UTC (01/01/1601)
// measured in 10ths of a microsecond (which is equal to 100 nanoseconds
// as is the increment for UTC)
#define EPOCH_UTC_TENTHMICROSECS_DELTA INT64_C(116444736000000000)

// include windows headers for obtaining time
#include <windows.h>

#ifndef __MINGW32__

// define timezone structure
struct timezone
{
   /**
    * The number of minutes west of Greenwich, England.
    */<commit_msg>Replaced obsolete ftime() function.<commit_after>/*
 * Copyright (c) 2007-2010 Digital Bazaar, Inc. All rights reserved.
 */
#ifndef monarch_rt_TimeFunctions_H
#define monarch_rt_TimeFunctions_H

/**
 * This header provides some cross-platform definitions for time functions.
 *
 * Primarily, this header defines functionality for missing POSIX time
 * functions in windows.
 *
 * FIXME: This header's code should be relocated to .c/.cpp.
 *
 * @author <NAME>
 */

// include types, time, and errno
#include <sys/types.h>
#include <sys/time.h>
#include <time.h>
#include <errno.h>
#include <inttypes.h>

//// prevent C++ name mangling
//#ifdef __cplusplus
//extern "C" {
//#endif

/**
 * Gets the number of minutes west of GMT the current time zone is.
 *
 * @return the number of minutes west of GMT the current time zone is.
 */
inline static int64_t gGetTimeZoneMinutesWest()
{
   // get local time, convert to GMT (UTC) and then subtract difference
   time_t localTime = time(NULL);
   struct tm brokenDown;
   gmtime_r(&localTime, &brokenDown);
   time_t utcTime = mktime(&brokenDown);
   return (utcTime - localTime) / 60;
}

#ifdef WIN32

// define time between the epoch (01/01/1970) and UTC (01/01/1601)
// measured in 10ths of a microsecond (which is equal to 100 nanoseconds
// as is the increment for UTC)
#define EPOCH_UTC_TENTHMICROSECS_DELTA INT64_C(116444736000000000)

// include windows headers for obtaining time
#include <windows.h>

#ifndef __MINGW32__

// define timezone structure
struct timezone
{
   /**
    * The number of minutes west of Greenwich, England.
    */
{'fraction_non_alphanumeric': 0.10587853199090613, 'fraction_numerical': 0.037349788892497564, 'mean_word_length': 3.645550527903469, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3587659', 'n_tokens_mistral': 1091, 'n_tokens_neox': 973, 'n_words': 353}