#ifndef __TiqMisc_h_ #define __TiqMisc_h_ #include #include #include #include "../../shared/MiscSupport.h" #include "../../shared/MarketHours.h" inline std::string formatPrice(double price) { return dtoaFixed(price, 2); } inline std::string formatTime(time_t time) { time = localToNy(time); struct tm brokenDown; localtime_r(&time, &brokenDown); char buffer[36*3 + 2 + 1]; // 3 longs, 2 colons, 1 null sprintf(buffer, "%02ld:%02ld:%02ld", (long)brokenDown.tm_hour, (long)brokenDown.tm_min, (long)brokenDown.tm_sec); return buffer; } inline std::string formatTimeMinutes(time_t time) { // Sometimes for one reason or another we get called a fraction of a second // before we should be. So we should be reporting at 10:00:00 but we are // reporting at 9:59:59.9999. If we don't round we'll report "9:59". When // we report seconds, it's not quite as bad. This specific function is only // called when we expect seconds to be 00. time += 15; time = localToNy(time); struct tm brokenDown; localtime_r(&time, &brokenDown); char buffer[36*2 + 1 + 1]; // 2 longs, 1 colon, 1 null. sprintf(buffer, "%02ld:%02ld", (long)brokenDown.tm_hour, (long)brokenDown.tm_min); return buffer; } #endif