[Scummvm-git-logs] scummvm master -> 71f3bee330047c5dbad2ae2ed04a0f7622af4685

sev- noreply at scummvm.org
Sun Jun 14 18:41:57 UTC 2026


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .

Summary:
cca0e910ad TWP: Remove time.h dependency
71f3bee330 COMMON: Utility functions for converting a TimeDate into an integer and vice versa


Commit: cca0e910adcd13998b1fb71a8bc7b516d067ceda
    https://github.com/scummvm/scummvm/commit/cca0e910adcd13998b1fb71a8bc7b516d067ceda
Author: scemino (scemino74 at gmail.com)
Date: 2026-06-14T20:41:52+02:00

Commit Message:
TWP: Remove time.h dependency

Changed paths:
    engines/twp/metaengine.cpp
    engines/twp/time.cpp
    engines/twp/time.h


diff --git a/engines/twp/metaengine.cpp b/engines/twp/metaengine.cpp
index f905d80246b..3c09db4ef93 100644
--- a/engines/twp/metaengine.cpp
+++ b/engines/twp/metaengine.cpp
@@ -83,7 +83,7 @@ const Common::AchievementDescriptionList *TwpMetaEngine::getAchievementDescripti
 }
 
 static Common::String getDesc(const Twp::SaveGame &savegame) {
-	Common::String desc = Twp::formatTime(savegame.time, "%b %d at %H:%M");
+	Common::String desc = Twp::formatTime(savegame.time);
 	if (savegame.easyMode)
 		desc += " (casual)";
 	return desc;
@@ -115,11 +115,11 @@ SaveStateDescriptor TwpMetaEngine::querySaveMetaInfos(const char *target, int sl
 		Twp::SaveGame savegame;
 		Twp::SaveGameManager::getSaveGame(f, savegame);
 		Common::String savegameDesc(getDesc(savegame));
-		Twp::DateTime dt = Twp::toDateTime(savegame.time);
+		TimeDate dt = Twp::intToTimeDate(savegame.time);
 		desc.setDescription(savegameDesc);
 		desc.setPlayTime(savegame.gameTime * 1000);
-		desc.setSaveDate(dt.year, dt.month, dt.day);
-		desc.setSaveTime(dt.hour, dt.min);
+		desc.setSaveDate(dt.tm_year, dt.tm_mon, dt.tm_mday);
+		desc.setSaveTime(dt.tm_hour, dt.tm_min);
 
 		return desc;
 	}
diff --git a/engines/twp/time.cpp b/engines/twp/time.cpp
index c645070b2c3..6dd2de9efed 100644
--- a/engines/twp/time.cpp
+++ b/engines/twp/time.cpp
@@ -19,34 +19,118 @@
  *
  */
 
-#define FORBIDDEN_SYMBOL_ALLOW_ALL
-#include <time.h>
+#include "common/system.h"
 #include "twp/time.h"
 
 namespace Twp {
 
-Common::String formatTime(int64 t, const char *format) {
-	time_t time = (time_t)t;
-	struct tm *tm = localtime(&time);
-	char buf[64];
-	strftime(buf, 64, format, tm);
-	return Common::String(buf);
+enum {
+	SECONDS_IN_DAY = 86400, // number of seconds in a day
+	SECONDS_IN_HOUR = 3600,// number of seconds in an hour
+	SECONDS_IN_MINUTE = 60
+};
+
+Common::String formatTime(int64 t) {
+	const char* monthList[12] = {
+		"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+	};
+	const TimeDate timeDate = intToTimeDate(t);
+	return Common::String::format( "%s %d at %.2d:%.2d", monthList[timeDate.tm_mon], timeDate.tm_mday, timeDate.tm_hour, timeDate.tm_min);
+}
+
+static bool isLeapYear(int year) {
+	return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
 }
 
-DateTime toDateTime(int64 t) {
-	time_t time = (time_t)t;
-	struct tm *tm = localtime(&time);
-	DateTime dateTime;
-	dateTime.year = 1900 + tm->tm_year;
-	dateTime.month = 1 + tm->tm_mon;
-	dateTime.day = tm->tm_mday;
-	dateTime.hour = tm->tm_hour;
-	dateTime.min = tm->tm_min;
+static int64_t dateTimeToInt64(const TimeDate &timeDate) {
+	const int64_t year  = (int64_t)timeDate.tm_year + 1900; // fixup year
+	const int month = timeDate.tm_mon;
+	const int days_in_month[2][12] = {
+		{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, // non-leap year
+		{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } // leap year, February has 29 days
+	};
+
+	// Count days from the Unix epoch (1970-01-01) to Jan 1 of `year`
+	/*
+	 * For a year Y, the number of leap years in [1, Y-1] is:
+	 *   floor((Y-1)/4) - floor((Y-1)/100) + floor((Y-1)/400)
+	 * Days from year 0 to Jan 1 of Y = 365*Y + leaps
+	 * Subtract the same value for 1970 to get the offset.
+	 */
+	const int64_t y0     = year  - 1;
+	const int64_t y1970  = 1969; // 1970 - 1
+
+	const int64_t leaps0    = y0    / 4 - y0    / 100 + y0    / 400;
+	const int64_t leaps1970 = y1970 / 4 - y1970 / 100 + y1970 / 400;
+
+	int64_t days = 365 * (year - 1970) + (leaps0 - leaps1970);
+
+	// add days for the months elapsed in the current year
+	const int leap = isLeapYear((int)year);
+	for (int m = 0; m < month; m++)
+		days += days_in_month[leap][m];
+
+	// add remaining date/time fields
+	days += (int64_t)timeDate.tm_mday - 1;
+
+	const int64_t seconds = days * SECONDS_IN_DAY
+		+ timeDate.tm_hour * SECONDS_IN_HOUR
+		+ timeDate.tm_min  * SECONDS_IN_MINUTE
+		+ timeDate.tm_sec;
+
+	return seconds;
+}
+
+TimeDate intToTimeDate(int64 t) {
+	TimeDate dateTime;
+	int64_t seconds = t;
+	dateTime.tm_sec = seconds % SECONDS_IN_MINUTE;
+	seconds /= SECONDS_IN_MINUTE;
+	dateTime.tm_min = seconds % 60;
+	seconds /= 60;
+	dateTime.tm_hour = seconds % 24;
+	seconds /= 24;
+
+	// Now `seconds` is the number of days since the Unix epoch (1970-01-01)
+	// We can find the year by subtracting the number of days in each year until we find the correct one.
+	int year = 1970;
+	while (true) {
+		const int days_in_year = isLeapYear(year) ? 366 : 365;
+		if (seconds >= days_in_year) {
+			seconds -= days_in_year;
+			year++;
+			continue;
+		}
+		break;
+	}
+	dateTime.tm_year = year - 1900; // fixup year
+
+	// Now `seconds` is the number of days elapsed in the current year. We can find the month and day similarly.
+	const int days_in_month[2][12] = {
+		{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, // non-leap year
+		{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }  // leap-year, February has 29 days
+	};
+	const int leap = isLeapYear(year);
+	int month = 0;
+	while (month < 12) {
+		const int dim = days_in_month[leap][month];
+		if (seconds >= dim) {
+			seconds -= dim;
+			month++;
+		} else {
+			break;
+		}
+	}
+	dateTime.tm_mon = month; // tm_mon is 0-based
+	dateTime.tm_mday = (int)seconds + 1;
+
 	return dateTime;
 }
 
 int64 getTime() {
-	return (int64)time(NULL);
+	TimeDate dateTimeTm;
+	g_system->getTimeAndDate(dateTimeTm);
+	return dateTimeToInt64(dateTimeTm);
 }
 
 } // namespace Twp
diff --git a/engines/twp/time.h b/engines/twp/time.h
index a7bbfb00391..822bcb237ab 100644
--- a/engines/twp/time.h
+++ b/engines/twp/time.h
@@ -26,13 +26,18 @@
 
 namespace Twp {
 
-struct DateTime {
-	int year, month, day;
-	int hour, min;
-};
+/// @brief Convert a time value (number of seconds since the Unix epoch) to a human-readable string format.
+/// @param t The time value to format, as a number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC).
+/// @return A formatted string representing the date and time, in the format "Mon DD at HH:MM", where Mon is the three-letter month abbreviation, DD is the day of the month, HH is the hour (00-23), and MM is the minute (00-59).
+Common::String formatTime(int64 t);
 
-Common::String formatTime(int64 time, const char *format);
-DateTime toDateTime(int64 time);
+/// @brief Convert a time value (number of seconds since the Unix epoch) to a TimeDate struct representing the corresponding date and time components.
+/// @param t The time value to convert, as a number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC).
+/// @return A TimeDate struct representing the date and time components.
+TimeDate intToTimeDate(int64 t);
+
+/// @brief Get the current time as a time value (number of seconds since the Unix epoch).
+/// @return The current time as a number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC).
 int64 getTime();
 
 } // namespace Twp


Commit: 71f3bee330047c5dbad2ae2ed04a0f7622af4685
    https://github.com/scummvm/scummvm/commit/71f3bee330047c5dbad2ae2ed04a0f7622af4685
Author: scemino (scemino74 at gmail.com)
Date: 2026-06-14T20:41:52+02:00

Commit Message:
COMMON: Utility functions for converting a TimeDate into an integer and vice versa

Changed paths:
  R engines/twp/time.cpp
  R engines/twp/time.h
    common/util.cpp
    common/util.h
    engines/twp/metaengine.cpp
    engines/twp/module.mk
    engines/twp/savegame.cpp


diff --git a/common/util.cpp b/common/util.cpp
index 4540f3bad33..b3c39aceff9 100644
--- a/common/util.cpp
+++ b/common/util.cpp
@@ -23,8 +23,15 @@
 
 #include "common/util.h"
 #include "common/debug.h"
+#include "common/system.h"
 #include "common/translation.h"
 
+enum {
+	SECONDS_IN_DAY = 86400, // number of seconds in a day
+	SECONDS_IN_HOUR = 3600, // number of seconds in an hour
+	SECONDS_IN_MINUTE = 60  // number of seconds in a minute
+};
+
 namespace Common {
 
 //
@@ -210,4 +217,112 @@ Common::String getHumanReadableBytes(uint64 bytes, const char *&unitsOut) {
 	return Common::String::format("%.1f", floating);
 }
 
+namespace DateTime {
+
+Common::String formatTime(int64 t) {
+	const char* monthList[12] = {
+		"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+	};
+	const TimeDate timeDate = int64ToTimeDate(t);
+	return Common::String::format("%s %d at %.2d:%.2d", monthList[timeDate.tm_mon], timeDate.tm_mday, timeDate.tm_hour, timeDate.tm_min);
+}
+
+static bool isLeapYear(int year) {
+	// https://learn.microsoft.com/en-us/troubleshoot/microsoft-365-apps/excel/determine-a-leap-year
+	return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
+}
+
+int64_t dateTimeToInt64(const TimeDate &timeDate) {
+	const int64_t year  = (int64_t)timeDate.tm_year + 1900; // fixup year
+	const int month = timeDate.tm_mon;
+	const int days_in_month[2][12] = {
+		{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, // non-leap year
+		{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } // leap year, February has 29 days
+	};
+
+	// Count days from the Unix epoch (1970-01-01) to Jan 1 of `year`
+	/*
+	 * For a year Y, the number of leap years in [1, Y-1] is:
+	 *   floor((Y-1)/4) - floor((Y-1)/100) + floor((Y-1)/400)
+	 * Days from year 0 to Jan 1 of Y = 365*Y + leaps
+	 * Subtract the same value for 1970 to get the offset.
+	 */
+	const int64_t y0     = year  - 1;
+	const int64_t y1970  = 1969; // 1970 - 1
+
+	const int64_t leaps0    = y0    / 4 - y0    / 100 + y0    / 400;
+	const int64_t leaps1970 = y1970 / 4 - y1970 / 100 + y1970 / 400;
+
+	int64_t days = 365 * (year - 1970) + (leaps0 - leaps1970);
+
+	// add days for the months elapsed in the current year
+	const int leap = isLeapYear((int)year);
+	for (int m = 0; m < month; m++)
+		days += days_in_month[leap][m];
+
+	// add remaining date/time fields
+	days += (int64_t)timeDate.tm_mday - 1;
+
+	const int64_t seconds = days * SECONDS_IN_DAY
+		+ timeDate.tm_hour * SECONDS_IN_HOUR
+		+ timeDate.tm_min  * SECONDS_IN_MINUTE
+		+ timeDate.tm_sec;
+
+	return seconds;
+}
+
+TimeDate int64ToTimeDate(int64 t) {
+	TimeDate dateTime;
+	int64_t seconds = t;
+	dateTime.tm_sec = seconds % SECONDS_IN_MINUTE;
+	seconds /= SECONDS_IN_MINUTE;
+	dateTime.tm_min = seconds % 60;
+	seconds /= 60;
+	dateTime.tm_hour = seconds % 24;
+	seconds /= 24;
+
+	// Now `seconds` is the number of days since the Unix epoch (1970-01-01)
+	// We can find the year by subtracting the number of days in each year until we find the correct one.
+	int year = 1970;
+	while (true) {
+		const int days_in_year = isLeapYear(year) ? 366 : 365;
+		if (seconds >= days_in_year) {
+			seconds -= days_in_year;
+			year++;
+			continue;
+		}
+		break;
+	}
+	dateTime.tm_year = year - 1900; // fixup year
+
+	// Now `seconds` is the number of days elapsed in the current year. We can find the month and day similarly.
+	const int days_in_month[2][12] = {
+		{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, // non-leap year
+		{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }  // leap-year, February has 29 days
+	};
+	const int leap = isLeapYear(year);
+	int month = 0;
+	while (month < 12) {
+		const int dim = days_in_month[leap][month];
+		if (seconds >= dim) {
+			seconds -= dim;
+			month++;
+			continue;
+		}
+		break;
+	}
+	dateTime.tm_mon = month; // tm_mon is 0-based
+	dateTime.tm_mday = (int)seconds + 1;
+
+	return dateTime;
+}
+
+int64 getTime() {
+	TimeDate dateTimeTm;
+	g_system->getTimeAndDate(dateTimeTm);
+	return dateTimeToInt64(dateTimeTm);
+}
+
+} // End of namespace DateTime
+
 } // End of namespace Common
diff --git a/common/util.h b/common/util.h
index e43460c4c10..517b65e3f03 100644
--- a/common/util.h
+++ b/common/util.h
@@ -26,6 +26,8 @@
 
 #include "common/type_traits.h"
 
+struct TimeDate;
+
 /**
  * @defgroup common_util Util
  * @ingroup common
@@ -411,6 +413,32 @@ bool isBlank(int c);
  */
 Common::String getHumanReadableBytes(uint64 bytes, const char *&unitsOut);
 
+/**
+ * Utility functions for converting a TimeDate structure into an integer representation of the time, and vice versa.
+ * The integer representation is the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC).
+ */
+namespace DateTime {
+	/**
+	 * Convert a time value (number of seconds since the Unix epoch) to a TimeDate struct representing the corresponding date and time components.
+	 */
+	TimeDate int64ToTimeDate(int64 integer);
+
+	/**
+	 * Convert a TimeDate struct representing date and time components to a time value (number of seconds since the Unix epoch).
+	 */
+	int64_t dateTimeToInt64(const TimeDate &timeDate);
+
+	/**
+	 * Convert a time value (number of seconds since the Unix epoch) to a human-readable string format.
+	 */
+	Common::String formatTime(int64 integer);
+
+	/**
+	 * Get the current time as a time value (number of seconds since the Unix epoch).
+	 */
+	int64 getTime();
+}
+
 /** @} */
 
 } // End of namespace Common
diff --git a/engines/twp/metaengine.cpp b/engines/twp/metaengine.cpp
index 3c09db4ef93..bc422cc8b03 100644
--- a/engines/twp/metaengine.cpp
+++ b/engines/twp/metaengine.cpp
@@ -37,7 +37,6 @@
 #include "twp/metaengine.h"
 #include "twp/detection.h"
 #include "twp/savegame.h"
-#include "twp/time.h"
 #include "twp/actions.h"
 #include "twp/debugtools.h"
 #include "twp/dialogs.h"
@@ -83,7 +82,7 @@ const Common::AchievementDescriptionList *TwpMetaEngine::getAchievementDescripti
 }
 
 static Common::String getDesc(const Twp::SaveGame &savegame) {
-	Common::String desc = Twp::formatTime(savegame.time);
+	Common::String desc = Common::DateTime::formatTime(savegame.time);
 	if (savegame.easyMode)
 		desc += " (casual)";
 	return desc;
@@ -115,7 +114,7 @@ SaveStateDescriptor TwpMetaEngine::querySaveMetaInfos(const char *target, int sl
 		Twp::SaveGame savegame;
 		Twp::SaveGameManager::getSaveGame(f, savegame);
 		Common::String savegameDesc(getDesc(savegame));
-		TimeDate dt = Twp::intToTimeDate(savegame.time);
+		TimeDate dt = Common::DateTime::int64ToTimeDate(savegame.time);
 		desc.setDescription(savegameDesc);
 		desc.setPlayTime(savegame.gameTime * 1000);
 		desc.setSaveDate(dt.tm_year, dt.tm_mon, dt.tm_mday);
diff --git a/engines/twp/module.mk b/engines/twp/module.mk
index fe7af221890..9375566c696 100644
--- a/engines/twp/module.mk
+++ b/engines/twp/module.mk
@@ -36,7 +36,6 @@ MODULE_OBJS = \
 	squtil.o \
 	syslib.o \
 	thread.o \
-	time.o \
 	tsv.o \
 	twp.o \
 	util.o \
diff --git a/engines/twp/savegame.cpp b/engines/twp/savegame.cpp
index 7c290a9a3ff..7d4a8157a67 100644
--- a/engines/twp/savegame.cpp
+++ b/engines/twp/savegame.cpp
@@ -32,7 +32,6 @@
 #include "twp/room.h"
 #include "twp/savegame.h"
 #include "twp/squtil.h"
-#include "twp/time.h"
 
 namespace Twp {
 
@@ -1090,7 +1089,7 @@ static Common::JSONValue *createSaveGame() {
 	json["objects"] = createJObjects();
 	json["rooms"] = createJRooms();
 	json["savebuild"] = new Common::JSONValue(958LL);
-	json["savetime"] = new Common::JSONValue((long long)getTime());
+	json["savetime"] = new Common::JSONValue((long long)Common::DateTime::getTime());
 	json["selectedActor"] = new Common::JSONValue(g_twp->_actor ? g_twp->_actor->_key : "");
 	json["version"] = new Common::JSONValue((long long int)2);
 	return new Common::JSONValue(json);
diff --git a/engines/twp/time.cpp b/engines/twp/time.cpp
deleted file mode 100644
index 6dd2de9efed..00000000000
--- a/engines/twp/time.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "common/system.h"
-#include "twp/time.h"
-
-namespace Twp {
-
-enum {
-	SECONDS_IN_DAY = 86400, // number of seconds in a day
-	SECONDS_IN_HOUR = 3600,// number of seconds in an hour
-	SECONDS_IN_MINUTE = 60
-};
-
-Common::String formatTime(int64 t) {
-	const char* monthList[12] = {
-		"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
-	};
-	const TimeDate timeDate = intToTimeDate(t);
-	return Common::String::format( "%s %d at %.2d:%.2d", monthList[timeDate.tm_mon], timeDate.tm_mday, timeDate.tm_hour, timeDate.tm_min);
-}
-
-static bool isLeapYear(int year) {
-	return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
-}
-
-static int64_t dateTimeToInt64(const TimeDate &timeDate) {
-	const int64_t year  = (int64_t)timeDate.tm_year + 1900; // fixup year
-	const int month = timeDate.tm_mon;
-	const int days_in_month[2][12] = {
-		{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, // non-leap year
-		{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } // leap year, February has 29 days
-	};
-
-	// Count days from the Unix epoch (1970-01-01) to Jan 1 of `year`
-	/*
-	 * For a year Y, the number of leap years in [1, Y-1] is:
-	 *   floor((Y-1)/4) - floor((Y-1)/100) + floor((Y-1)/400)
-	 * Days from year 0 to Jan 1 of Y = 365*Y + leaps
-	 * Subtract the same value for 1970 to get the offset.
-	 */
-	const int64_t y0     = year  - 1;
-	const int64_t y1970  = 1969; // 1970 - 1
-
-	const int64_t leaps0    = y0    / 4 - y0    / 100 + y0    / 400;
-	const int64_t leaps1970 = y1970 / 4 - y1970 / 100 + y1970 / 400;
-
-	int64_t days = 365 * (year - 1970) + (leaps0 - leaps1970);
-
-	// add days for the months elapsed in the current year
-	const int leap = isLeapYear((int)year);
-	for (int m = 0; m < month; m++)
-		days += days_in_month[leap][m];
-
-	// add remaining date/time fields
-	days += (int64_t)timeDate.tm_mday - 1;
-
-	const int64_t seconds = days * SECONDS_IN_DAY
-		+ timeDate.tm_hour * SECONDS_IN_HOUR
-		+ timeDate.tm_min  * SECONDS_IN_MINUTE
-		+ timeDate.tm_sec;
-
-	return seconds;
-}
-
-TimeDate intToTimeDate(int64 t) {
-	TimeDate dateTime;
-	int64_t seconds = t;
-	dateTime.tm_sec = seconds % SECONDS_IN_MINUTE;
-	seconds /= SECONDS_IN_MINUTE;
-	dateTime.tm_min = seconds % 60;
-	seconds /= 60;
-	dateTime.tm_hour = seconds % 24;
-	seconds /= 24;
-
-	// Now `seconds` is the number of days since the Unix epoch (1970-01-01)
-	// We can find the year by subtracting the number of days in each year until we find the correct one.
-	int year = 1970;
-	while (true) {
-		const int days_in_year = isLeapYear(year) ? 366 : 365;
-		if (seconds >= days_in_year) {
-			seconds -= days_in_year;
-			year++;
-			continue;
-		}
-		break;
-	}
-	dateTime.tm_year = year - 1900; // fixup year
-
-	// Now `seconds` is the number of days elapsed in the current year. We can find the month and day similarly.
-	const int days_in_month[2][12] = {
-		{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, // non-leap year
-		{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }  // leap-year, February has 29 days
-	};
-	const int leap = isLeapYear(year);
-	int month = 0;
-	while (month < 12) {
-		const int dim = days_in_month[leap][month];
-		if (seconds >= dim) {
-			seconds -= dim;
-			month++;
-		} else {
-			break;
-		}
-	}
-	dateTime.tm_mon = month; // tm_mon is 0-based
-	dateTime.tm_mday = (int)seconds + 1;
-
-	return dateTime;
-}
-
-int64 getTime() {
-	TimeDate dateTimeTm;
-	g_system->getTimeAndDate(dateTimeTm);
-	return dateTimeToInt64(dateTimeTm);
-}
-
-} // namespace Twp
diff --git a/engines/twp/time.h b/engines/twp/time.h
deleted file mode 100644
index 822bcb237ab..00000000000
--- a/engines/twp/time.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef TWP_TIME_H
-#define TWP_TIME_H
-
-#include "common/str.h"
-
-namespace Twp {
-
-/// @brief Convert a time value (number of seconds since the Unix epoch) to a human-readable string format.
-/// @param t The time value to format, as a number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC).
-/// @return A formatted string representing the date and time, in the format "Mon DD at HH:MM", where Mon is the three-letter month abbreviation, DD is the day of the month, HH is the hour (00-23), and MM is the minute (00-59).
-Common::String formatTime(int64 t);
-
-/// @brief Convert a time value (number of seconds since the Unix epoch) to a TimeDate struct representing the corresponding date and time components.
-/// @param t The time value to convert, as a number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC).
-/// @return A TimeDate struct representing the date and time components.
-TimeDate intToTimeDate(int64 t);
-
-/// @brief Get the current time as a time value (number of seconds since the Unix epoch).
-/// @return The current time as a number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC).
-int64 getTime();
-
-} // namespace Twp
-
-#endif




More information about the Scummvm-git-logs mailing list