From 1a284890a23188378db268500eb406f5505ff81b Mon Sep 17 00:00:00 2001
From: MadCamel <madcamel@gmail.com>
Date: Sun, 26 Apr 2009 20:15:52 +0000
Subject: Changed all times to use UTC

---
 src/char/char.c       |  2 +-
 src/login/login.c     | 42 +++++++++++++++++++++---------------------
 src/login_sql/login.c |  8 ++++----
 src/map/atcommand.c   |  2 +-
 src/map/chrif.c       |  2 +-
 src/map/clif.c        |  6 +++---
 src/map/npc.c         |  2 +-
 src/map/pc.c          |  2 +-
 src/map/script.c      |  6 +++---
 9 files changed, 36 insertions(+), 36 deletions(-)

(limited to 'src')

diff --git a/src/char/char.c b/src/char/char.c
index 82a1723..e82c955 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -128,7 +128,7 @@ int char_log(char *fmt, ...) {
 			fprintf(logfp, RETCODE);
 		else {
 			gettimeofday(&tv, NULL);
-			strftime(tmpstr, 24, "%d-%m-%Y %H:%M:%S", localtime(&(tv.tv_sec)));
+			strftime(tmpstr, 24, "%d-%m-%Y %H:%M:%S", gmtime(&(tv.tv_sec)));
 			sprintf(tmpstr + 19, ".%03d: %s", (int)tv.tv_usec / 1000, fmt);
 			vfprintf(logfp, tmpstr, ap);
 		}
diff --git a/src/login/login.c b/src/login/login.c
index defe9a6..e7ae640 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -148,7 +148,7 @@ int login_log(char *fmt, ...) {
 			fprintf(logfp, RETCODE);
 		else {
 			gettimeofday(&tv, NULL);
-			strftime(tmpstr, 24, date_format, localtime(&(tv.tv_sec)));
+			strftime(tmpstr, 24, date_format, gmtime(&(tv.tv_sec)));
 			sprintf(tmpstr + strlen(tmpstr), ".%03d: %s", (int)tv.tv_usec / 1000, fmt);
 			vfprintf(logfp, tmpstr, ap);
 		}
@@ -975,7 +975,7 @@ int mmo_auth_new(struct mmo_account* account, char sex, char* email) {
 	else { // limited time
 		timestamp = time(NULL) + start_limited_time;
 		// double conversion to be sure that it is possible
-		tmtime = localtime(&timestamp);
+		tmtime = gmtime(&timestamp);
 		timestamp_temp = mktime(tmtime);
 		if (timestamp_temp != -1 && (timestamp_temp + 3600) >= timestamp) // check possible value and overflow (and avoid summer/winter hour)
 			auth_dat[i].connect_until_time = timestamp_temp;
@@ -1113,7 +1113,7 @@ int mmo_auth(struct mmo_account* account, int fd) {
 		}
 
 		if (auth_dat[i].ban_until_time != 0) { // if account is banned
-			strftime(tmpstr, 20, date_format, localtime(&auth_dat[i].ban_until_time));
+			strftime(tmpstr, 20, date_format, gmtime(&auth_dat[i].ban_until_time));
 			tmpstr[19] = '\0';
 			if (auth_dat[i].ban_until_time > time(NULL)) { // always banned
 				login_log("Connection refused (account: %s, pass: %s, banned until %s, ip: %s)" RETCODE,
@@ -1147,7 +1147,7 @@ int mmo_auth(struct mmo_account* account, int fd) {
 	}
 
 	gettimeofday(&tv, NULL);
-	strftime(tmpstr, 24, date_format, localtime(&(tv.tv_sec)));
+	strftime(tmpstr, 24, date_format, gmtime(&(tv.tv_sec)));
 	sprintf(tmpstr + strlen(tmpstr), ".%03d", (int)tv.tv_usec / 1000);
 
 	account->account_id = auth_dat[i].account_id;
@@ -1376,7 +1376,7 @@ int parse_fromchar(int fd) {
 								char tmpstr[24];
 								struct timeval tv;
 								gettimeofday(&tv, NULL);
-								strftime(tmpstr, 23, date_format, localtime(&(tv.tv_sec)));
+								strftime(tmpstr, 23, date_format, gmtime(&(tv.tv_sec)));
 								fprintf(fp, RETCODE "// %s: @GM command on account %d" RETCODE "%d %d" RETCODE, tmpstr, acc, acc, level_new_gm);
 								fclose(fp);
 								WBUFL(buf,6) = level_new_gm;
@@ -1511,7 +1511,7 @@ int parse_fromchar(int fd) {
 							timestamp = time(NULL);
 						else
 							timestamp = auth_dat[i].ban_until_time;
-						tmtime = localtime(&timestamp);
+						tmtime = gmtime(&timestamp);
 						tmtime->tm_year = tmtime->tm_year + (short)RFIFOW(fd,6);
 						tmtime->tm_mon = tmtime->tm_mon + (short)RFIFOW(fd,8);
 						tmtime->tm_mday = tmtime->tm_mday + (short)RFIFOW(fd,10);
@@ -1526,7 +1526,7 @@ int parse_fromchar(int fd) {
 								if (timestamp != 0) {
 									unsigned char buf[16];
 									char tmpstr[2048];
-									strftime(tmpstr, 24, date_format, localtime(&timestamp));
+									strftime(tmpstr, 24, date_format, gmtime(&timestamp));
 									login_log("Char-server '%s': Ban request (account: %d, new final date of banishment: %d (%s), ip: %s)." RETCODE,
 									          server[id].name, acc, timestamp, (timestamp == 0 ? "no banishment" : tmpstr), ip);
 									WBUFW(buf,0) = 0x2731;
@@ -1677,7 +1677,7 @@ int parse_fromchar(int fd) {
 				logfp = fopen(login_log_unknown_packets_filename, "a");
 				if (logfp) {
 					gettimeofday(&tv, NULL);
-					strftime(tmpstr, 23, date_format, localtime(&(tv.tv_sec)));
+					strftime(tmpstr, 23, date_format, gmtime(&(tv.tv_sec)));
 					fprintf(logfp, "%s.%03d: receiving of an unknown packet -> disconnection" RETCODE, tmpstr, (int)tv.tv_usec / 1000);
 					fprintf(logfp, "parse_fromchar: connection #%d (ip: %s), packet: 0x%x (with being read: %d)." RETCODE, fd, ip, RFIFOW(fd,0), RFIFOREST(fd));
 					fprintf(logfp, "Detail (in hex):" RETCODE);
@@ -2123,7 +2123,7 @@ int parse_admin(int fd) {
 							if ((fp2 = lock_fopen(GM_account_filename, &lock)) != NULL) {
 								if ((fp = fopen(GM_account_filename, "r")) != NULL) {
 									gettimeofday(&tv, NULL);
-									strftime(tmpstr, 23, date_format, localtime(&(tv.tv_sec)));
+									strftime(tmpstr, 23, date_format, gmtime(&(tv.tv_sec)));
 									modify_flag = 0;
 									// read/write GM file
 									while(fgets(line, sizeof(line)-1, fp)) {
@@ -2309,7 +2309,7 @@ int parse_admin(int fd) {
 				account_name[23] = '\0';
 				remove_control_chars(account_name);
 				timestamp = (time_t)RFIFOL(fd,26);
-				strftime(tmpstr, 24, date_format, localtime(&timestamp));
+				strftime(tmpstr, 24, date_format, gmtime(&timestamp));
 				i = search_account_index(account_name);
 				if (i != -1) {
 					memcpy(WFIFOP(fd,6), auth_dat[i].userid, 24);
@@ -2343,7 +2343,7 @@ int parse_admin(int fd) {
 				timestamp = (time_t)RFIFOL(fd,26);
 				if (timestamp <= time(NULL))
 					timestamp = 0;
-				strftime(tmpstr, 24, date_format, localtime(&timestamp));
+				strftime(tmpstr, 24, date_format, gmtime(&timestamp));
 				i = search_account_index(account_name);
 				if (i != -1) {
 					memcpy(WFIFOP(fd,6), auth_dat[i].userid, 24);
@@ -2396,7 +2396,7 @@ int parse_admin(int fd) {
 						timestamp = time(NULL);
 					else
 						timestamp = auth_dat[i].ban_until_time;
-					tmtime = localtime(&timestamp);
+					tmtime = gmtime(&timestamp);
 					tmtime->tm_year = tmtime->tm_year + (short)RFIFOW(fd,26);
 					tmtime->tm_mon = tmtime->tm_mon + (short)RFIFOW(fd,28);
 					tmtime->tm_mday = tmtime->tm_mday + (short)RFIFOW(fd,30);
@@ -2407,7 +2407,7 @@ int parse_admin(int fd) {
 					if (timestamp != -1) {
 						if (timestamp <= time(NULL))
 							timestamp = 0;
-						strftime(tmpstr, 24, date_format, localtime(&timestamp));
+						strftime(tmpstr, 24, date_format, gmtime(&timestamp));
 						login_log("'ladmin': Adjustment of a final date of a banishment (account: %s, (%+d y %+d m %+d d %+d h %+d mn %+d s) -> new validity: %d (%s), ip: %s)" RETCODE,
 						          auth_dat[i].userid, (short)RFIFOW(fd,26), (short)RFIFOW(fd,28), (short)RFIFOW(fd,30), (short)RFIFOW(fd,32), (short)RFIFOW(fd,34), (short)RFIFOW(fd,36), timestamp, (timestamp == 0 ? "no banishment" : tmpstr), ip);
 						if (auth_dat[i].ban_until_time != timestamp) {
@@ -2426,7 +2426,7 @@ int parse_admin(int fd) {
 							mmo_auth_sync();
 						}
 					} else {
-						strftime(tmpstr, 24, date_format, localtime(&auth_dat[i].ban_until_time));
+						strftime(tmpstr, 24, date_format, gmtime(&auth_dat[i].ban_until_time));
 						login_log("'ladmin': Impossible to adjust the final date of a banishment (account: %s, %d (%s) + (%+d y %+d m %+d d %+d h %+d mn %+d s) -> ???, ip: %s)" RETCODE,
 						          auth_dat[i].userid, auth_dat[i].ban_until_time, (auth_dat[i].ban_until_time == 0 ? "no banishment" : tmpstr), (short)RFIFOW(fd,26), (short)RFIFOW(fd,28), (short)RFIFOW(fd,30), (short)RFIFOW(fd,32), (short)RFIFOW(fd,34), (short)RFIFOW(fd,36), ip);
 					}
@@ -2507,7 +2507,7 @@ int parse_admin(int fd) {
 					} else {
 						if (timestamp == 0 || timestamp < time(NULL))
 							timestamp = time(NULL);
-						tmtime = localtime(&timestamp);
+						tmtime = gmtime(&timestamp);
 						tmtime->tm_year = tmtime->tm_year + (short)RFIFOW(fd,26);
 						tmtime->tm_mon = tmtime->tm_mon + (short)RFIFOW(fd,28);
 						tmtime->tm_mday = tmtime->tm_mday + (short)RFIFOW(fd,30);
@@ -2516,15 +2516,15 @@ int parse_admin(int fd) {
 						tmtime->tm_sec = tmtime->tm_sec + (short)RFIFOW(fd,36);
 						timestamp = mktime(tmtime);
 						if (timestamp != -1) {
-							strftime(tmpstr, 24, date_format, localtime(&auth_dat[i].connect_until_time));
-							strftime(tmpstr2, 24, date_format, localtime(&timestamp));
+							strftime(tmpstr, 24, date_format, gmtime(&auth_dat[i].connect_until_time));
+							strftime(tmpstr2, 24, date_format, gmtime(&timestamp));
 							login_log("'ladmin': Adjustment of a validity limit (account: %s, %d (%s) + (%+d y %+d m %+d d %+d h %+d mn %+d s) -> new validity: %d (%s), ip: %s)" RETCODE,
 							          auth_dat[i].userid, auth_dat[i].connect_until_time, (auth_dat[i].connect_until_time == 0 ? "unlimited" : tmpstr), (short)RFIFOW(fd,26), (short)RFIFOW(fd,28), (short)RFIFOW(fd,30), (short)RFIFOW(fd,32), (short)RFIFOW(fd,34), (short)RFIFOW(fd,36), timestamp, (timestamp == 0 ? "unlimited" : tmpstr2), ip);
 							auth_dat[i].connect_until_time = timestamp;
 							mmo_auth_sync();
 							WFIFOL(fd,30) = (unsigned long)auth_dat[i].connect_until_time;
 						} else {
-							strftime(tmpstr, 24, date_format, localtime(&auth_dat[i].connect_until_time));
+							strftime(tmpstr, 24, date_format, gmtime(&auth_dat[i].connect_until_time));
 							login_log("'ladmin': Impossible to adjust a validity limit (account: %s, %d (%s) + (%+d y %+d m %+d d %+d h %+d mn %+d s) -> ???, ip: %s)" RETCODE,
 							          auth_dat[i].userid, auth_dat[i].connect_until_time, (auth_dat[i].connect_until_time == 0 ? "unlimited" : tmpstr), (short)RFIFOW(fd,26), (short)RFIFOW(fd,28), (short)RFIFOW(fd,30), (short)RFIFOW(fd,32), (short)RFIFOW(fd,34), (short)RFIFOW(fd,36), ip);
 							WFIFOL(fd,30) = 0;
@@ -2635,7 +2635,7 @@ int parse_admin(int fd) {
 				logfp = fopen(login_log_unknown_packets_filename, "a");
 				if (logfp) {
 					gettimeofday(&tv, NULL);
-					strftime(tmpstr, 23, date_format, localtime(&(tv.tv_sec)));
+					strftime(tmpstr, 23, date_format, gmtime(&(tv.tv_sec)));
 					fprintf(logfp, "%s.%03d: receiving of an unknown packet -> disconnection" RETCODE, tmpstr, (int)tv.tv_usec / 1000);
 					fprintf(logfp, "parse_admin: connection #%d (ip: %s), packet: 0x%x (with being read: %d)." RETCODE, fd, ip, RFIFOW(fd,0), RFIFOREST(fd));
 					fprintf(logfp, "Detail (in hex):" RETCODE);
@@ -2870,7 +2870,7 @@ int parse_login(int fd) {
 					if (i != -1) {
 						if (auth_dat[i].ban_until_time != 0) { // if account is banned, we send ban timestamp
 							char tmpstr[256];
-							strftime(tmpstr, 20, date_format, localtime(&auth_dat[i].ban_until_time));
+							strftime(tmpstr, 20, date_format, gmtime(&auth_dat[i].ban_until_time));
 							tmpstr[19] = '\0';
 							memcpy(WFIFOP(fd,3), tmpstr, 20);
 						} else { // we send error message
@@ -3070,7 +3070,7 @@ int parse_login(int fd) {
 				logfp = fopen(login_log_unknown_packets_filename, "a");
 				if (logfp) {
 					gettimeofday(&tv, NULL);
-					strftime(tmpstr, 23, date_format, localtime(&(tv.tv_sec)));
+					strftime(tmpstr, 23, date_format, gmtime(&(tv.tv_sec)));
 					fprintf(logfp, "%s.%03d: receiving of an unknown packet -> disconnection" RETCODE, tmpstr, (int)tv.tv_usec / 1000);
 					fprintf(logfp, "parse_login: connection #%d (ip: %s), packet: 0x%x (with being read: %d)." RETCODE, fd, ip, RFIFOW(fd,0), RFIFOREST(fd));
 					fprintf(logfp, "Detail (in hex):" RETCODE);
diff --git a/src/login_sql/login.c b/src/login_sql/login.c
index 2fab051..60a6f68 100644
--- a/src/login_sql/login.c
+++ b/src/login_sql/login.c
@@ -337,7 +337,7 @@ int mmo_auth( struct mmo_account* account , int fd){
 
 	// auth start : time seed
 	gettimeofday(&tv, NULL);
-	strftime(tmpstr, 24, "%Y-%m-%d %H:%M:%S",localtime(&(tv.tv_sec)));
+	strftime(tmpstr, 24, "%Y-%m-%d %H:%M:%S",gmtime(&(tv.tv_sec)));
 	sprintf(tmpstr+19, ".%03d", (int)tv.tv_usec/1000);
 
 	jstrescapecpy(t_uid,account->userid);
@@ -502,7 +502,7 @@ int mmo_auth( struct mmo_account* account , int fd){
 
 	//login {0-account_id/1-userid/2-user_pass/3-lastlogin/4-logincount/5-sex/6-connect_untl/7-last_ip/8-ban_until/9-state}
 	if (ban_until_time != 0) { // if account is banned
-		strftime(tmpstr, 20, date_format, localtime(&ban_until_time));
+		strftime(tmpstr, 20, date_format, gmtime(&ban_until_time));
 		tmpstr[19] = '\0';
 		if (ban_until_time > time(NULL)) { // always banned
 			return 6; // 6 = Your are Prohibited to log in until %s
@@ -843,7 +843,7 @@ int parse_fromchar(int fd){
 				timestamp = time(NULL);
 			else
 				timestamp = tmptime;
-			tmtime = localtime(&timestamp);
+			tmtime = gmtime(&timestamp);
 			tmtime->tm_year = tmtime->tm_year + (short)RFIFOW(fd,6);
 			tmtime->tm_mon = tmtime->tm_mon + (short)RFIFOW(fd,8);
 			tmtime->tm_mday = tmtime->tm_mday + (short)RFIFOW(fd,10);
@@ -1267,7 +1267,7 @@ int parse_login(int fd) {
 					char tmpstr[256];
 					time_t ban_until_time;
 					ban_until_time = atol(sql_row[0]);
-					strftime(tmpstr, 20, date_format, localtime(&ban_until_time));
+					strftime(tmpstr, 20, date_format, gmtime(&ban_until_time));
 					tmpstr[19] = '\0';
 					memcpy(WFIFOP(fd,3), tmpstr, 20);
 				} else { // we send error message
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 07751bd..a981607 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -5222,7 +5222,7 @@ int atcommand_servertime(const int fd, struct map_session_data* sd,
 	memset(temp, '\0', sizeof(temp));
 
 	time(&time_server);  // get time in seconds since 1/1/1970
-	datetime = localtime(&time_server); // convert seconds in structure
+	datetime = gmtime(&time_server); // convert seconds in structure
 	// like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
 	strftime(temp, sizeof(temp)-1, msg_table[230], datetime); // Server time (normal time): %A, %B %d %Y %X.
 	clif_displaymessage(fd, temp);
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 40972f4..05fa603 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -805,7 +805,7 @@ int chrif_accountban(int fd)
 				char tmpstr[2048];
 				timestamp = (time_t)RFIFOL(fd,7); // status or final date of a banishment
 				strcpy(tmpstr, "Your account has been banished until ");
-				strftime(tmpstr + strlen(tmpstr), 24, "%d-%m-%Y %H:%M:%S", localtime(&timestamp));
+				strftime(tmpstr + strlen(tmpstr), 24, "%d-%m-%Y %H:%M:%S", gmtime(&timestamp));
 				clif_displaymessage(sd->fd, tmpstr);
 			}
 			clif_setwaitclose(sd->fd); // forced to disconnect for the change
diff --git a/src/map/clif.c b/src/map/clif.c
index 25ce1d4..7a80bd2 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -8435,11 +8435,11 @@ static int clif_parse(int fd) {
 					if (sd && sd->state.auth) {
 						if (sd->status.name != NULL)
 							fprintf(fp, "%sPlayer with account ID %d (character ID %d, player name %s) sent wrong packet:\n",
-							        asctime(localtime(&now)), sd->status.account_id, sd->status.char_id, sd->status.name);
+							        asctime(gmtime(&now)), sd->status.account_id, sd->status.char_id, sd->status.name);
 						else
-							fprintf(fp, "%sPlayer with account ID %d sent wrong packet:\n", asctime(localtime(&now)), sd->bl.id);
+							fprintf(fp, "%sPlayer with account ID %d sent wrong packet:\n", asctime(gmtime(&now)), sd->bl.id);
 					} else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified)
-						fprintf(fp, "%sPlayer with account ID %d sent wrong packet:\n", asctime(localtime(&now)), sd->bl.id);
+						fprintf(fp, "%sPlayer with account ID %d sent wrong packet:\n", asctime(gmtime(&now)), sd->bl.id);
 
 					fprintf(fp, "\t---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");
 					for(i = 0; i < packet_len; i++) {
diff --git a/src/map/npc.c b/src/map/npc.c
index fa01d56..11725b3 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -349,7 +349,7 @@ int npc_event_do_clock(int tid,unsigned int tick,int id,int data)
 	int c=0;
 	
 	time(&timer);
-	t=localtime(&timer);
+	t=gmtime(&timer);
 	
 	if (t->tm_min != ev_tm_b.tm_min ) {
 		sprintf(buf,"OnMinute%02d",t->tm_min);
diff --git a/src/map/pc.c b/src/map/pc.c
index 2ac5ce1..982adea 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -818,7 +818,7 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, short tmw_versio
 	// message of the limited time of the account
 	if (connect_until_time != 0) { // don't display if it's unlimited or unknow value
 		char tmpstr[1024];
-		strftime(tmpstr, sizeof(tmpstr) - 1, msg_txt(501), localtime(&connect_until_time)); // "Your account time limit is: %d-%m-%Y %H:%M:%S."
+		strftime(tmpstr, sizeof(tmpstr) - 1, msg_txt(501), gmtime(&connect_until_time)); // "Your account time limit is: %d-%m-%Y %H:%M:%S."
 		clif_wis_message(sd->fd, wisp_server_name, tmpstr, strlen(tmpstr)+1);
 	}
 
diff --git a/src/map/script.c b/src/map/script.c
index a8d9a83..48071d0 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -3437,7 +3437,7 @@ int buildin_gettimetick(struct script_state *st)	/* Asgard Version */
 	case 1:
 		//type 1:(Second Ticks: 0-86399, 00:00:00-23:59:59)
 		time(&timer);
-		t=localtime(&timer);
+		t=gmtime(&timer);
 		push_val(st->stack,C_INT,((t->tm_hour)*3600+(t->tm_min)*60+t->tm_sec));
 		break;
 	case 0:
@@ -3465,7 +3465,7 @@ int buildin_gettime(struct script_state *st)	/* Asgard Version */
 	type=conv_num(st,& (st->stack->stack_data[st->start+2]));
 
 	time(&timer);
-	t=localtime(&timer);
+	t=gmtime(&timer);
 
 	switch(type){
 	case 1://Sec(0~59)
@@ -3511,7 +3511,7 @@ int buildin_gettimestr(struct script_state *st)
 	maxlen=conv_num(st,& (st->stack->stack_data[st->start+3]));
 
 	tmpstr=(char *)aCalloc(maxlen+1,sizeof(char));
-	strftime(tmpstr,maxlen,fmtstr,localtime(&now));
+	strftime(tmpstr,maxlen,fmtstr,gmtime(&now));
 	tmpstr[maxlen]='\0';
 
 	push_str(st->stack,C_STR,tmpstr);
-- 
cgit v1.2.3-70-g09d2