MCPcopy Create free account
hub / github.com/Kitware/CMake / AddTimestampComponent

Method AddTimestampComponent

Source/cmTimestamp.cxx:190–332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

188}
189
190std::string cmTimestamp::AddTimestampComponent(
191 char flag, struct tm& timeStruct, time_t const timeT, bool const utcFlag,
192 uint32_t const microseconds) const
193{
194 std::string formatString = cmStrCat('%', flag);
195
196 switch (flag) {
197 case 'a':
198 case 'A':
199 case 'b':
200 case 'B':
201 case 'd':
202 case 'H':
203 case 'I':
204 case 'j':
205 case 'm':
206 case 'M':
207 case 'S':
208 case 'U':
209 case 'V':
210 case 'w':
211 case 'y':
212 case 'Y':
213 case '%':
214 break;
215 case 'Z':
216#if defined(__GLIBC__)
217 // 'struct tm' has the time zone, so strftime can honor UTC.
218 static_cast<void>(utcFlag);
219#else
220 // 'struct tm' may not have the time zone, so strftime may
221 // use local time. Hard-code the UTC result.
222 if (utcFlag) {
223 return std::string("GMT");
224 }
225#endif
226 break;
227 case 'z': {
228#if defined(__GLIBC__)
229 // 'struct tm' has the time zone, so strftime can honor UTC.
230 static_cast<void>(utcFlag);
231#else
232 // 'struct tm' may not have the time zone, so strftime may
233 // use local time. Hard-code the UTC result.
234 if (utcFlag) {
235 return std::string("+0000");
236 }
237#endif
238#ifndef _AIX
239 break;
240#else
241 std::string xpg_sus_old;
242 bool const xpg_sus_was_set =
243 cmSystemTools::GetEnv("XPG_SUS_ENV", xpg_sus_old);
244 if (xpg_sus_was_set && xpg_sus_old == "ON") {
245 break;
246 }
247 xpg_sus_old = "XPG_SUS_ENV=" + xpg_sus_old;

Callers 1

Calls 6

CreateUtcTimeTFromTmMethod · 0.95
to_stringFunction · 0.85
lengthMethod · 0.80
c_strMethod · 0.80
cmStrCatFunction · 0.70
ErrorClass · 0.70

Tested by

no test coverage detected