Browse Source

修改时间戳错误的问题

vothin 1 year ago
parent
commit
7edb285735

+ 16 - 3
jni/include/utils/TimeHelper.h

@@ -72,9 +72,22 @@ public:
 	}
 
 	static time_t getDateline() {
-		time_t now;
-		time(&now);
-		return now;
+//		time_t timep;
+//		struct tm *p;
+//
+//		time(&timep);
+//		p = gmtime(&timep);
+		struct tm *tm_ = TimeHelper::getDateTime();
+//	    tm_->tm_year = tm_->tm_year - 1900;                 // 年,由于tm结构体存储的是从1900年开始的时间,所以tm_year为int临时变量减去1900。
+//	    tm_->tm_mon = tm_->tm_mon - 1;                    // 月,由于tm结构体的月份存储范围为0-11,所以tm_mon为int临时变量减去1。
+//	    tm_->tm_mday = tm_->tm_mday;                         // 日。
+	    tm_->tm_hour = tm_->tm_hour - 8;                        // 时。
+//	    tm_->tm_min = tm_->tm_min;                       // 分。
+//	    tm_->tm_sec = tm_->tm_sec;                       // 秒。
+//	    tm_->tm_isdst = 0;                          // 非夏令时。
+
+	    time_t t_ = mktime(tm_);                  // 将tm结构体转换成time_t格式。
+	    return t_;                                 // 返回值。
 	}
 };
 

+ 3 - 2
jni/logic/mainLogic.cc

@@ -389,12 +389,13 @@ public:
 					Json::Value operationData;
 					Reader.parse(root[i]["operation_data"].asString(), operationData);
 					int seconds = operationData["seconds"].asInt();
-					if (now - root[i]["start_time"].asInt() > seconds) {
+
+					if (now - root[i]["start_time"].asInt() < seconds) {
 						setPromptTimeItId(root[i]["id"].asInt());
 
 						Intent* intent = new Intent();
 						intent->putExtra(promptText2, operationData["tips"].asString());
-						intent->putExtra(promptTime2, to_string(seconds));
+						intent->putExtra(promptTime2, to_string(seconds - (now - root[i]["start_time"].asInt())));
 						EASYUICONTEXT->openActivity("promptActivity", intent);
 					}
 					else {

+ 0 - 1
jni/logic/promptLogic.cc

@@ -174,7 +174,6 @@ static bool onUI_Timer(int id){
 			mPromptWindowPtr->hideWnd();
 			mSetPromptWindowPtr->showWnd();
 
-
 		    if (promptTimeItId != 0) {
 		    	sendPromptQuit(promptTimeItId);
 		    }

BIN
libs/armeabi/libzkgui.so


BIN
obj/activity/mainActivity.o


BIN
obj/service/time.o