blob: 7cc7d61908d1a7e84be4e58521ce0d6b32373ecc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#include "units.hpp"
#include <sstream>
#include <cstring>
#include <iostream>
namespace unit {
std::string
Time::format(const char *fmt)
{
std::stringstream ss;
for(; *fmt; fmt++) {
if(*fmt != '%') {
ss << *fmt;
continue;
}
fmt++;
switch(*fmt) {
case '%':
ss << '%';
break;
case 'Y':
ss << real_years();
break;
case 'C':
ss << years();
break;
case 'S': {
Time year = current_year();
ss << month_str[year.months()];
break; }
case 'M': {
Time year = current_year();
ss << year.months();
break; }
case 'W': {
Time month = current_month();
ss << month.weeks();
break; }
case 'D': {
Time month = current_month();
ss << month.days();
break; }
case 'H': {
Time day = current_day();
ss << day.hours();
break; }
case 'm': {
Time hour = current_hour();
ss << hour.minutes();
break; }
case 's': {
Time minute = current_minute();
ss << minute.seconds();
break; }
}
}
return ss.str();
}
}
|