| 1073 | static const char* MONTH_ABRVS[] = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}; |
| 1074 | |
| 1075 | int FormatTime(const ImPlotTime& t, char* buffer, int size, ImPlotTimeFmt fmt, bool use_24_hr_clk) { |
| 1076 | tm& Tm = GImPlot->Tm; |
| 1077 | GetTime(t, &Tm); |
| 1078 | const int us = t.Us % 1000; |
| 1079 | const int ms = t.Us / 1000; |
| 1080 | const int sec = Tm.tm_sec; |
| 1081 | const int min = Tm.tm_min; |
| 1082 | if (use_24_hr_clk) { |
| 1083 | const int hr = Tm.tm_hour; |
| 1084 | switch(fmt) { |
| 1085 | case ImPlotTimeFmt_Us: return ImFormatString(buffer, size, ".%03d %03d", ms, us); |
| 1086 | case ImPlotTimeFmt_SUs: return ImFormatString(buffer, size, ":%02d.%03d %03d", sec, ms, us); |
| 1087 | case ImPlotTimeFmt_SMs: return ImFormatString(buffer, size, ":%02d.%03d", sec, ms); |
| 1088 | case ImPlotTimeFmt_S: return ImFormatString(buffer, size, ":%02d", sec); |
| 1089 | case ImPlotTimeFmt_MinSMs: return ImFormatString(buffer, size, ":%02d:%02d.%03d", min, sec, ms); |
| 1090 | case ImPlotTimeFmt_HrMinSMs: return ImFormatString(buffer, size, "%02d:%02d:%02d.%03d", hr, min, sec, ms); |
| 1091 | case ImPlotTimeFmt_HrMinS: return ImFormatString(buffer, size, "%02d:%02d:%02d", hr, min, sec); |
| 1092 | case ImPlotTimeFmt_HrMin: return ImFormatString(buffer, size, "%02d:%02d", hr, min); |
| 1093 | case ImPlotTimeFmt_Hr: return ImFormatString(buffer, size, "%02d:00", hr); |
| 1094 | default: return 0; |
| 1095 | } |
| 1096 | } |
| 1097 | else { |
| 1098 | const char* ap = Tm.tm_hour < 12 ? "am" : "pm"; |
| 1099 | const int hr = (Tm.tm_hour == 0 || Tm.tm_hour == 12) ? 12 : Tm.tm_hour % 12; |
| 1100 | switch(fmt) { |
| 1101 | case ImPlotTimeFmt_Us: return ImFormatString(buffer, size, ".%03d %03d", ms, us); |
| 1102 | case ImPlotTimeFmt_SUs: return ImFormatString(buffer, size, ":%02d.%03d %03d", sec, ms, us); |
| 1103 | case ImPlotTimeFmt_SMs: return ImFormatString(buffer, size, ":%02d.%03d", sec, ms); |
| 1104 | case ImPlotTimeFmt_S: return ImFormatString(buffer, size, ":%02d", sec); |
| 1105 | case ImPlotTimeFmt_MinSMs: return ImFormatString(buffer, size, ":%02d:%02d.%03d", min, sec, ms); |
| 1106 | case ImPlotTimeFmt_HrMinSMs: return ImFormatString(buffer, size, "%d:%02d:%02d.%03d%s", hr, min, sec, ms, ap); |
| 1107 | case ImPlotTimeFmt_HrMinS: return ImFormatString(buffer, size, "%d:%02d:%02d%s", hr, min, sec, ap); |
| 1108 | case ImPlotTimeFmt_HrMin: return ImFormatString(buffer, size, "%d:%02d%s", hr, min, ap); |
| 1109 | case ImPlotTimeFmt_Hr: return ImFormatString(buffer, size, "%d%s", hr, ap); |
| 1110 | default: return 0; |
| 1111 | } |
| 1112 | } |
| 1113 | } |
| 1114 | |
| 1115 | int FormatDate(const ImPlotTime& t, char* buffer, int size, ImPlotDateFmt fmt, bool use_iso_8601) { |
| 1116 | tm& Tm = GImPlot->Tm; |
no test coverage detected