diff options
Diffstat (limited to '_PROGRAMs/C++/TIME.md')
| -rw-r--r-- | _PROGRAMs/C++/TIME.md | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/_PROGRAMs/C++/TIME.md b/_PROGRAMs/C++/TIME.md new file mode 100644 index 0000000..9643b06 --- /dev/null +++ b/_PROGRAMs/C++/TIME.md @@ -0,0 +1,26 @@ + +```C++ +String timeCalc(uint32_t t) { + uint32_t timer = t / 1000; + uint32_t timeSec = (timer % 3600) % 60; + uint32_t timeMin = (timer % 3600) / 60; + uint32_t timeHour = timer / 3600 % 24; + uint32_t timeDay = timer / 60 / 60 / 24; + String s = ""; + s += timeDay; + s += ":"; + if (timeHour < 10) + s += "0"; + s += timeHour; + s += ":"; + if (timeMin < 10) + s += "0"; + s += timeMin; + s += ":"; + if (timeSec < 10) + s += "0"; + s += timeSec; + return s; +} +``` + |
