需求#23635 【桌面环境】【文管浏览体验升级】默认显示相对日期,允许用户切换到绝对日期
This commit is contained in:
parent
ce3c135b6b
commit
3dcf39ad2e
|
@ -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
|
||||
|
|
BIN
po/zh_CN.mo
BIN
po/zh_CN.mo
Binary file not shown.
12
po/zh_CN.po
12
po/zh_CN.po
|
@ -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 "今天"
|
||||
|
|
BIN
po/zh_HK.mo
BIN
po/zh_HK.mo
Binary file not shown.
12
po/zh_HK.po
12
po/zh_HK.po
|
@ -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 "今天"
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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* 成功返回字符串{今天,明天},失败返回NULL;返回的字符串需要free释放。
|
||||
*/
|
||||
extern char* kdk_system_tran_absolute_date(struct tm *ptr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue