From 6e9340a48af6370294e218496c304a7e574838b0 Mon Sep 17 00:00:00 2001 From: kormax <3392860+kormax@users.noreply.github.com> Date: Sun, 2 Aug 2026 23:36:44 +0300 Subject: [PATCH] Detect and print FeliCa manufacturing time --- client/src/cmdhffelica.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/client/src/cmdhffelica.c b/client/src/cmdhffelica.c index 99a0843e0..2d85de937 100644 --- a/client/src/cmdhffelica.c +++ b/client/src/cmdhffelica.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "cmdparser.h" // command_t #include "comms.h" #include "cmdtrace.h" @@ -2397,6 +2398,18 @@ static int info_felica(bool verbose) { PrintAndLogEx(INFO, " Code......... " _GREEN_("%s"), sprint_hex_inrow(card.code, sizeof(card.code))); } PrintAndLogEx(INFO, " NFCID2....... " _GREEN_("%s"), sprint_hex_inrow(card.uid, sizeof(card.uid))); + const int16_t days_since_2000 = (int16_t)(((uint16_t)card.IDm[5] << 8) | card.IDm[4]); + const time_t felica_epoch = (time_t)946684800; // 2000-01-01 UTC + const time_t now = time(NULL); + if (days_since_2000 >= 0 && now != (time_t)-1 && now >= felica_epoch && + (time_t)days_since_2000 <= (now - felica_epoch) / 86400) { + const time_t manufacturing_time = felica_epoch + ((time_t)days_since_2000 * 86400); + const struct tm *date = gmtime(&manufacturing_time); + char date_string[11] = {0}; + if (date != NULL && strftime(date_string, sizeof(date_string), "%Y-%m-%d", date) != 0) { + PrintAndLogEx(INFO, " Mfg date..... " _GREEN_("%s"), date_string); + } + } PrintAndLogEx(INFO, "PMM............ " _YELLOW_("%s"), sprint_hex_inrow(card.PMm, sizeof(card.PMm))); PrintAndLogEx(INFO, " IC code...... " _GREEN_("%s") " ( %s )", sprint_hex_inrow(card.iccode, sizeof(card.iccode)),