timelib.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #ifndef TIMELIB_INCL
  14. #define TIMELIB_INCL
  15. #ifdef _WIN32
  16. #define TIMELIB_CALL _cdecl
  17. #ifdef TIMELIB_EXPORTS
  18. #define TIMELIB_API __declspec(dllexport)
  19. #else
  20. #define TIMELIB_API __declspec(dllimport)
  21. #endif
  22. #else
  23. #define TIMELIB_CALL
  24. #define TIMELIB_API
  25. #endif
  26. #include <time.h>
  27. #include "platform.h"
  28. #include "hqlplugins.hpp"
  29. extern "C" {
  30. #ifdef TIMELIB_EXPORTS
  31. TIMELIB_API bool getECLPluginDefinition(ECLPluginDefinitionBlock *pb);
  32. TIMELIB_API void setPluginContext(IPluginContext * _ctx);
  33. #endif
  34. void tlMakeTimeStructFromUTCSeconds(time_t seconds, struct tm* timeInfo);
  35. void tlInsertDateIntoTimeStruct(struct tm* timeInfo, unsigned int date);
  36. unsigned int tlExtractDateFromTimeStruct(struct tm* timeInfo);
  37. void tlInsertTimeIntoTimeStruct(struct tm* timeInfo, unsigned int time);
  38. unsigned int tlExtractTimeFromTimeStruct(struct tm* timeInfo);
  39. TIMELIB_API time_t TIMELIB_CALL tlSecondsFromParts(int year, unsigned int month, unsigned int day, unsigned int hour, unsigned int minute, unsigned int second, bool is_local_time = false);
  40. TIMELIB_API void TIMELIB_CALL tlSecondsToParts(size32_t &__lenResult, void* &__result, time_t seconds);
  41. TIMELIB_API unsigned int TIMELIB_CALL tlGetDayOfYear(short year, unsigned short month, unsigned short day);
  42. TIMELIB_API unsigned int TIMELIB_CALL tlGetDayOfWeek(short year, unsigned short month, unsigned short day);
  43. TIMELIB_API void TIMELIB_CALL tlDateToString(size32_t &__lenResult, char* &__result, unsigned int date, const char* format);
  44. TIMELIB_API void TIMELIB_CALL tlTimeToString(size32_t &__lenResult, char* &__result, unsigned int time, const char* format);
  45. TIMELIB_API unsigned int TIMELIB_CALL tlAdjustDate(unsigned int date, short year_delta, int month_delta, int day_delta);
  46. TIMELIB_API void TIMELIB_CALL tlSecondsToString(size32_t &__lenResult, char* &__result, int seconds, const char* format);
  47. TIMELIB_API unsigned int TIMELIB_CALL tlAdjustDateBySeconds(unsigned int date, int seconds_delta);
  48. TIMELIB_API unsigned int TIMELIB_CALL tlAdjustTime(unsigned int time, short hour_delta, int minute_delta, int second_delta);
  49. TIMELIB_API unsigned int TIMELIB_CALL tlAdjustTimeBySeconds(unsigned int time, int seconds_delta);
  50. TIMELIB_API time_t TIMELIB_CALL tlAdjustSeconds(time_t seconds, short year_delta, int month_delta, int day_delta, short hour_delta, int minute_delta, int second_delta);
  51. TIMELIB_API unsigned int TIMELIB_CALL tlAdjustCalendar(unsigned int date, short year_delta, int month_delta, int day_delta);
  52. TIMELIB_API bool TIMELIB_CALL tlIsLocalDaylightSavingsInEffect();
  53. TIMELIB_API int TIMELIB_CALL tlLocalTimeZoneOffset();
  54. TIMELIB_API unsigned int TIMELIB_CALL tlCurrentDate(bool in_local_time);
  55. TIMELIB_API unsigned int TIMELIB_CALL tlCurrentTime(bool in_local_time);
  56. TIMELIB_API time_t TIMELIB_CALL tlCurrentSeconds(bool in_local_time);
  57. TIMELIB_API double TIMELIB_CALL tlCurrentTimestamp(bool in_local_time);
  58. TIMELIB_API unsigned int TIMELIB_CALL tlGetLastDayOfMonth(unsigned int date);
  59. TIMELIB_API void TIMELIB_CALL tlDatesForWeek(size32_t &__lenResult, void* &__result, unsigned int date);
  60. }
  61. #endif