Login Page - Create Account

Support Board


Date/Time: Mon, 15 Sep 2025 13:34:37 +0000



Post From: [Programming help] transferring an ISO date to SCDateTime

[2025-09-14 20:34:39]
swish - Posts: 3
Thanks to both of you. I ended up doing this, it may not be the most effecient way but it worked for my purposes:

Working with the SCDateTime Variables and Values: SetDateTimeYMDHMS()
SCDateTime sc_datetime;
SCString timeStr((const char*)time_str);
std::string t((const char*)timeStr);

for (auto& c : t) if (c == 'T') c = ' ';

if (!t.empty() && t.back() == 'Z')
t.pop_back();

size_t dotPos = t.find('.');
if (dotPos != std::string::npos)
t = t.substr(0, dotPos);

int year, month, day, hour, minute, second;

sscanf(t.c_str(), "%d-%d-%d %d:%d:%d",
&year, &month, &day, &hour, &minute, &second);
sc_datetime.SetDateTimeYMDHMS(year, month, day, hour, minute, second);

Date Time Of Last Edit: 2025-09-14 20:35:46