timelib.hpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #else
  18. #define TIMELIB_CALL
  19. #endif
  20. #ifdef TIMELIB_EXPORTS
  21. #define TIMELIB_API DECL_EXPORT
  22. #else
  23. #define TIMELIB_API DECL_IMPORT
  24. #endif
  25. #include <time.h>
  26. #include "platform.h"
  27. #include "hqlplugins.hpp"
  28. #include "eclinclude4.hpp"
  29. #include "eclrtl.hpp"
  30. extern "C" {
  31. #ifdef TIMELIB_EXPORTS
  32. TIMELIB_API bool getECLPluginDefinition(ECLPluginDefinitionBlock *pb);
  33. TIMELIB_API void setPluginContext(IPluginContext * _ctx);
  34. #endif
  35. void tlMakeTimeStructFromSeconds(time_t seconds, struct tm* timeInfo, bool inLocalTimeZone);
  36. void tlInsertDateIntoTimeStruct(struct tm* timeInfo, unsigned int date);
  37. unsigned int tlExtractDateFromTimeStruct(const struct tm* timeInfo);
  38. void tlInsertTimeIntoTimeStruct(struct tm* timeInfo, unsigned int time);
  39. unsigned int tlExtractTimeFromTimeStruct(const struct tm* timeInfo);
  40. void tlLocalTime_r(const time_t* clock, struct tm* timeInfoPtr);
  41. void tlGMTime_r(const time_t* clock, struct tm* timeInfoPtr);
  42. time_t tlMKTime(struct tm* timeInfoPtr, bool inLocalTimeZone = true);
  43. TIMELIB_API __int64 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);
  44. TIMELIB_API size32_t TIMELIB_CALL tlSecondsToParts(ARowBuilder & __self, __int64 seconds, bool is_local_time);
  45. TIMELIB_API unsigned int TIMELIB_CALL tlGetDayOfYear(short year, unsigned short month, unsigned short day);
  46. TIMELIB_API unsigned int TIMELIB_CALL tlGetDayOfWeek(short year, unsigned short month, unsigned short day);
  47. TIMELIB_API void TIMELIB_CALL tlDateToString(size32_t &__lenResult, char* &__result, unsigned int date, const char* format);
  48. TIMELIB_API void TIMELIB_CALL tlTimeToString(size32_t &__lenResult, char* &__result, unsigned int time, const char* format);
  49. TIMELIB_API unsigned int TIMELIB_CALL tlAdjustDate(unsigned int date, short year_delta, int month_delta, int day_delta);
  50. TIMELIB_API void TIMELIB_CALL tlSecondsToString(size32_t &__lenResult, char* &__result, __int64 seconds, const char* format);
  51. TIMELIB_API unsigned int TIMELIB_CALL tlAdjustDateBySeconds(unsigned int date, int seconds_delta);
  52. TIMELIB_API unsigned int TIMELIB_CALL tlAdjustTime(unsigned int time, short hour_delta, int minute_delta, int second_delta);
  53. TIMELIB_API unsigned int TIMELIB_CALL tlAdjustTimeBySeconds(unsigned int time, int seconds_delta);
  54. TIMELIB_API __int64 TIMELIB_CALL tlAdjustSeconds(__int64 seconds, short year_delta, int month_delta, int day_delta, short hour_delta, int minute_delta, int second_delta);
  55. TIMELIB_API unsigned int TIMELIB_CALL tlAdjustCalendar(unsigned int date, short year_delta, int month_delta, int day_delta);
  56. TIMELIB_API bool TIMELIB_CALL tlIsLocalDaylightSavingsInEffect();
  57. TIMELIB_API int TIMELIB_CALL tlLocalTimeZoneOffset();
  58. TIMELIB_API unsigned int TIMELIB_CALL tlCurrentDate(bool in_local_time);
  59. TIMELIB_API unsigned int TIMELIB_CALL tlCurrentTime(bool in_local_time);
  60. TIMELIB_API __int64 TIMELIB_CALL tlCurrentSeconds(bool in_local_time);
  61. TIMELIB_API __int64 TIMELIB_CALL tlCurrentTimestamp(bool in_local_time);
  62. TIMELIB_API unsigned int TIMELIB_CALL tlGetLastDayOfMonth(unsigned int date);
  63. TIMELIB_API size32_t TIMELIB_CALL tlDatesForWeek(ARowBuilder & __self, unsigned int date);
  64. }
  65. #endif