需求#23635 【桌面环境】【文管浏览体验升级】默认显示相对日期,允许用户切换到绝对日期

This commit is contained in:
shaozhimin 2023-10-30 15:34:09 +08:00
parent ce3c135b6b
commit 3dcf39ad2e
8 changed files with 94 additions and 3 deletions

9
debian/changelog vendored
View File

@ -1,3 +1,12 @@
libkysdk-system (2.3.0.0-0k3.0) nile; urgency=medium
* BUG:无
* 需求号23635 【桌面环境】【文管浏览体验升级】默认显示相对日期,允许用户切换到绝对日期
* 其他改动说明:无
* 其他改动影响域:无
-- szm-min <shaozhimin@kylinos.cn> Mon, 30 Oct 2023 15:32:27 +0800
libkysdk-system (2.3.0.0-0k2.6) nile; urgency=medium
* BUG:19841

Binary file not shown.

View File

@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-08-16 14:41+0800\n"
"PO-Revision-Date: 2022-08-19 09:56+0800\n"
"PO-Revision-Date: 2023-10-23 15:37+0800\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@ -263,3 +263,13 @@ msgstr "上午%I:%M:%S"
#, c-format
msgid "%s_year%s_mon%s_day"
msgstr "%s年%s月%s日"
#: src/systemtime/libkydate.c:2867
#, c-format
msgid "Yesterday"
msgstr "昨天"
#: src/systemtime/libkydate.c:2877
#, c-format
msgid "Today"
msgstr "今天"

Binary file not shown.

View File

@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-08-16 14:41+0800\n"
"PO-Revision-Date: 2023-09-27 09:07+0800\n"
"PO-Revision-Date: 2023-10-23 15:35+0800\n"
"Last-Translator: Qingqing <wangyiqing@kylinos.cn>\n"
"Language-Team: Chinese (Traditional) <http://weblate.openkylin.top/projects/"
"kysdk-system-master/kysdk-system/zh_Hant/>\n"
@ -237,3 +237,13 @@ msgstr "下午%I%M%S"
#: src/systemtime/libkydate.c:1332
msgid "am%I:%M:%S"
msgstr "上午%I%M%S"
#: src/systemtime/libkydate.c:2867
#, c-format
msgid "Yesterday"
msgstr "昨天"
#: src/systemtime/libkydate.c:2877
#, c-format
msgid "Today"
msgstr "今天"

View File

@ -2857,6 +2857,52 @@ kdk_timeinfo *kdk_system_timeformat_transform(struct tm *ptr)
return res;
}
char* kdk_system_tran_absolute_date(struct tm *ptr)
{
setlocale (LC_ALL, "");
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
textdomain (GETTEXT_PACKAGE);
char *absDate = (char *)malloc(sizeof(char) * 64);
if(!absDate)
{
return NULL;
}
memset(absDate, 0, 64);
char *lang = getenv("LANG");
time_t timep;
time(&timep);
struct tm *p;
p = localtime(&timep);
int ySpace = (p->tm_year + 1900) - ptr->tm_year;
int mSpace = (p->tm_mon + 1) - ptr->tm_mon;
int dSpace = p->tm_mday - ptr->tm_mday;
if(ySpace != 0 || mSpace != 0 || dSpace > 1)
{
absDate = kdk_system_shortformat_transform(ptr);
}
else if(ySpace == 0 && mSpace == 0 && dSpace == 1)
{
if(strstr(lang, "zh_CN") || strstr(lang, "zh_HK"))
{
strcpy(absDate, gettext("Yesterday"));
}
else
absDate = kdk_system_shortformat_transform(ptr);
}
else if(ySpace == 0 && mSpace == 0 && dSpace == 0)
{
if(strstr(lang, "zh_CN") || strstr(lang, "zh_HK"))
{
strcpy(absDate, gettext("Today"));
}
else
absDate = kdk_system_shortformat_transform(ptr);
}
return absDate;
}
void kdk_free_timeinfo(kdk_timeinfo *time)
{
SAFE_FREE(time->time);

View File

@ -267,6 +267,14 @@ extern kdk_timeinfo *kdk_system_timeformat_transform(struct tm *ptr);
*/
extern void kdk_free_timeinfo(kdk_timeinfo *time);
/**
* @brief
* @param struct tm
*
* @return char* {}NULLfree释放
*/
extern char* kdk_system_tran_absolute_date(struct tm *ptr);
#ifdef __cplusplus
}
#endif

View File

@ -145,7 +145,15 @@ int main()
printf("time = %s, timesec = %s\n", ti->time, ti->timesec);
kdk_free_timeinfo(ti);
ptr.tm_year = 2023;
ptr.tm_mon = 10;
ptr.tm_mday = 22;
ptr.tm_hour = 14;
ptr.tm_min = 53;
ptr.tm_sec = 21;
char *absDate = kdk_system_tran_absolute_date(&ptr);
printf("absDate = %s\n", absDate);
free(absDate);
// free(tvalue);
return 0;