1 /* ctime.stp - Convert seconds to human readable date string.
3 * Copyright (C) 2012 Red Hat, Inc.
6 /* NB: functionally equivalent to linux/ctime.stp
7 * This means unlike normal userspace ctime(), this version
8 * returns time in UTC, without a final newline.
16 function ctime:string(epochsecs:long)
21 const time_t t = STAP_ARG_epochsecs;
23 if (gmtime_r(&t, &gmt) && asctime_r(&gmt, buf)) {
24 char* newline = strchr(buf, '\n');
27 strlcpy (STAP_RETVALUE, buf, MAXSTRINGLEN);
29 #if STAP_COMPAT_VERSION <= STAP_VERSION(2,2)
30 strlcpy(STAP_RETVALUE, "<invalid time>", MAXSTRINGLEN);
32 CONTEXT->last_error = "Time cannot be converted";