MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / FormatDate

Function FormatDate

Source/3rdParty/implot/implot.cpp:1153–1180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1151}
1152
1153int FormatDate(const ImPlotTime& t, char* buffer, int size, ImPlotDateFmt fmt, bool use_iso_8601) {
1154 tm& Tm = GImPlot->Tm;
1155 GetTime(t, &Tm);
1156 const int day = Tm.tm_mday;
1157 const int mon = Tm.tm_mon + 1;
1158 const int year = Tm.tm_year + 1900;
1159 const int yr = year % 100;
1160 if (use_iso_8601) {
1161 switch (fmt) {
1162 case ImPlotDateFmt_DayMo: return ImFormatString(buffer, size, "--%02d-%02d", mon, day);
1163 case ImPlotDateFmt_DayMoYr: return ImFormatString(buffer, size, "%d-%02d-%02d", year, mon, day);
1164 case ImPlotDateFmt_MoYr: return ImFormatString(buffer, size, "%d-%02d", year, mon);
1165 case ImPlotDateFmt_Mo: return ImFormatString(buffer, size, "--%02d", mon);
1166 case ImPlotDateFmt_Yr: return ImFormatString(buffer, size, "%d", year);
1167 default: return 0;
1168 }
1169 }
1170 else {
1171 switch (fmt) {
1172 case ImPlotDateFmt_DayMo: return ImFormatString(buffer, size, "%d/%d", mon, day);
1173 case ImPlotDateFmt_DayMoYr: return ImFormatString(buffer, size, "%d/%d/%02d", mon, day, yr);
1174 case ImPlotDateFmt_MoYr: return ImFormatString(buffer, size, "%s %d", MONTH_ABRVS[Tm.tm_mon], year);
1175 case ImPlotDateFmt_Mo: return ImFormatString(buffer, size, "%s", MONTH_ABRVS[Tm.tm_mon]);
1176 case ImPlotDateFmt_Yr: return ImFormatString(buffer, size, "%d", year);
1177 default: return 0;
1178 }
1179 }
1180 }
1181
1182int FormatDateTime(const ImPlotTime& t, char* buffer, int size, ImPlotDateTimeSpec fmt) {
1183 int written = 0;

Callers 2

PlotCandlestickFunction · 0.85
FormatDateTimeFunction · 0.85

Calls 2

ImFormatStringFunction · 0.85
GetTimeFunction · 0.70

Tested by

no test coverage detected