| 1061 | } |
| 1062 | |
| 1063 | ImPlotTime FloorTime(const ImPlotTime& t, ImPlotTimeUnit unit) { |
| 1064 | ImPlotContext& gp = *GImPlot; |
| 1065 | GetTime(t, &gp.Tm); |
| 1066 | switch (unit) { |
| 1067 | case ImPlotTimeUnit_S: return ImPlotTime(t.S, 0); |
| 1068 | case ImPlotTimeUnit_Ms: return ImPlotTime(t.S, (t.Us / 1000) * 1000); |
| 1069 | case ImPlotTimeUnit_Us: return t; |
| 1070 | case ImPlotTimeUnit_Yr: gp.Tm.tm_mon = 0; // fall-through |
| 1071 | case ImPlotTimeUnit_Mo: gp.Tm.tm_mday = 1; // fall-through |
| 1072 | case ImPlotTimeUnit_Day: gp.Tm.tm_hour = 0; // fall-through |
| 1073 | case ImPlotTimeUnit_Hr: gp.Tm.tm_min = 0; // fall-through |
| 1074 | case ImPlotTimeUnit_Min: gp.Tm.tm_sec = 0; break; |
| 1075 | default: return t; |
| 1076 | } |
| 1077 | return MkTime(&gp.Tm); |
| 1078 | } |
| 1079 | |
| 1080 | ImPlotTime CeilTime(const ImPlotTime& t, ImPlotTimeUnit unit) { |
| 1081 | return AddTime(FloorTime(t, unit), unit, 1); |
no test coverage detected