MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / timeToS3Time

Function timeToS3Time

launcher/minecraft/ParseUtils.cpp:12–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10}
11
12QString timeToS3Time(QDateTime time)
13{
14 // this all because Qt can't format timestamps right.
15 int offsetRaw = time.offsetFromUtc();
16 bool negative = offsetRaw < 0;
17 int offsetAbs = std::abs(offsetRaw);
18
19 int offsetSeconds = offsetAbs % 60;
20 offsetAbs -= offsetSeconds;
21
22 int offsetMinutes = offsetAbs % 3600;
23 offsetAbs -= offsetMinutes;
24 offsetMinutes /= 60;
25
26 int offsetHours = offsetAbs / 3600;
27
28 QString raw = time.toString("yyyy-MM-ddTHH:mm:ss");
29 raw += (negative ? QChar('-') : QChar('+'));
30 raw += QString("%1").arg(offsetHours, 2, 10, QChar('0'));
31 raw += ":";
32 raw += QString("%1").arg(offsetMinutes, 2, 10, QChar('0'));
33 return raw;
34}

Callers 2

test_ThroughMethod · 0.85

Calls 2

QStringClass · 0.85
toStringMethod · 0.45

Tested by 1

test_ThroughMethod · 0.68