mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Global: use time string when generating JSON result
This commit is contained in:
+8
-11
@@ -2,12 +2,11 @@
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/parsing.h"
|
||||
#include "common/percent.h"
|
||||
#include "common/time.h"
|
||||
#include "detection/disk/disk.h"
|
||||
#include "modules/disk/disk.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#define FF_DISK_NUM_FORMAT_ARGS 12
|
||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
|
||||
@@ -115,12 +114,6 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
|
||||
bool isHidden = !!(disk->type & FF_DISK_VOLUME_TYPE_HIDDEN_BIT);
|
||||
bool isReadOnly = !!(disk->type & FF_DISK_VOLUME_TYPE_READONLY_BIT);
|
||||
|
||||
char buf[64] = "";
|
||||
if(disk->createTime)
|
||||
{
|
||||
time_t time = (time_t) (disk->createTime / 1000);
|
||||
strftime(buf, sizeof(buf), "%FT%T%z", localtime(&time));
|
||||
}
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_DISK_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty},
|
||||
@@ -133,7 +126,7 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &disk->filesystem},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &disk->name},
|
||||
{FF_FORMAT_ARG_TYPE_BOOL, &isReadOnly},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, buf},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, ffTimeToShortStr(disk->createTime)},
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -459,7 +452,11 @@ void ffGenerateDiskJsonResult(FFDiskOptions* options, yyjson_mut_doc* doc, yyjso
|
||||
if(item->type & FF_DISK_VOLUME_TYPE_READONLY_BIT)
|
||||
yyjson_mut_arr_add_str(doc, typeArr, "Read-only");
|
||||
|
||||
yyjson_mut_obj_add_uint(doc, obj, "createTime", item->createTime);
|
||||
const char* pstr = ffTimeToFullStr(item->createTime);
|
||||
if (*pstr)
|
||||
yyjson_mut_obj_add_strcpy(doc, obj, "createTime", pstr);
|
||||
else
|
||||
yyjson_mut_obj_add_null(doc, obj, "createTime");
|
||||
}
|
||||
|
||||
FF_LIST_FOR_EACH(FFDisk, item, disks)
|
||||
@@ -485,7 +482,7 @@ void ffPrintDiskHelpFormat(void)
|
||||
"Filesystem",
|
||||
"Label / name",
|
||||
"True if read-only",
|
||||
"Create time",
|
||||
"Create time in local timezone",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user