---
name: "kdk_system_timeformat_transform"
section: "3"
platform: "linux"
package: "libkysdk-system"
version: "3.0.1.4-1"
release: "Arch Linux 2026-11-07"
platforms: ["linux"]
url: "https://carta.tech/man/kdk_system_timeformat_transform"
---

# kdk\_system\_timeformat\_transform(3)

时间格式转化

## NAME

kdk\_system\_timeformat\_transform - 时间格式转化

## SYNOPSIS

```
#include <libkydate.h>

extern kdk_timeinfo *kdk_system_timeformat_transform(struct tm *ptr);

Link with -lkydate.
```

## Detailed Description

The main function of this interface is to convert the time obtained from the struct tm of the standard library into  a structure in the user settings format.

The argument *ptr* It is a pointer to *struct tm.*

## RETURN VALUE

On success, returns a pointer to a *kdk\_timeinfo* structure is defined in *\<libkydate.h\>* as follows:\
         typedef struct \_kdk\_timeinfo{\
             char \*time;   // 时间\
             char \*timesec;  //带秒钟数时间\
         }kdk\_timeinfo;

On error, return **NULL.**

## EXAMPLES

```
#include "libkydate.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <glib.h>
#include <glib-object.h>
int main()
{
	int ret = kdk_system_set_long_dateformat("2230年3月4日");
	ret = kdk_system_set_short_dateformat("22/5/3");
	char *ld = kdk_system_get_longformat_date();
	printf("long res = %s0, ld);
	free(ld);
	char *sd = kdk_system_get_shortformat_date();
	printf("short res = %s0, sd);
	free(sd);
	char *ll = kdk_system_get_longformat();
	printf("longformat = %s0, ll);
	free(ll);
	char *ss = kdk_system_get_shortformat();
	printf("shortformat = %s0, ss);
	free(ss);
	struct tm ptr;
	ptr.tm_year = 2322;
	ptr.tm_mon = 9;
	ptr.tm_mday = 3;
	char *lt = kdk_system_longformat_transform(&ptr);
	printf("longformat_transform = %s0, lt);
	free(lt);
	ptr.tm_year = 2022;
	ptr.tm_mon = 3;
	ptr.tm_mday = 2;
	char *st = kdk_system_shortformat_transform(&ptr);
	printf("shortformat_transform = %s0, st);
	free(st);
	kdk_logn_dateinfo *info = kdk_system_login_lock_dateinfo("szm");
	printf("date = %s,time = %s,week = %s0,info->date,info->time,info->week);
	kdk_free_logn_dateinfo(info);
	ptr.tm_hour = 19;
	ptr.tm_min = 3;
	ptr.tm_sec = 2;
	kdk_timeinfo *ti = kdk_system_timeformat_transform(&ptr);
	printf("time = %s, timesec = %s0, ti->time, ti->timesec);
	kdk_free_timeinfo(ti);
    return 0;
}
```

## CONFORMING TO

These functions are as per the withdrawn POSIX.1e draft specification. The following functions are Linux extensions: **kdk\_system\_get\_dateformat**(), **kdk\_system\_set\_dateformat**(), **kdk\_system\_set\_24\_timeformat**(), **kdk\_system\_set\_12\_timeformat**(), **kdk\_system\_get\_now\_dateformat**(), **kdk\_system\_get\_now\_timeformat**(), **kdk\_system\_tran\_dateformat**(), **kdk\_system\_nowtime**(), **kdk\_system\_nowdate**(), **kdk\_system\_shortweek**(), **kdk\_system\_longweek**(), **kdk\_system\_second**(), **kdk\_system\_logn\_dateinfo**(), **kdk\_system\_gjx\_time**(), **kdk\_date\_freeall**(), **kdk\_free\_dateinfo**(), **kdk\_free\_logn\_dateinfo**(), **kdk\_system\_set\_long\_dateformat**(), **kdk\_system\_set\_short\_dateformat**(), **kdk\_system\_get\_longformat\_date**(), **kdk\_system\_get\_shortformat\_date**(), **kdk\_system\_get\_longformat**(), **kdk\_system\_get\_shortformat**(), **kdk\_system\_longformat\_transform**(), **kdk\_system\_shortformat\_transform**(), **kdk\_system\_login\_lock\_dateinfo**() and **kdk\_free\_timeinfo**().

## SEE ALSO

[**kdk\_system\_get\_dateformat**(3)](/man/kdk_system_get_dateformat/3.md), [**kdk\_system\_set\_dateformat**(3)](/man/kdk_system_set_dateformat/3.md), [**kdk\_system\_set\_24\_timeformat**(3)](/man/kdk_system_set_24_timeformat/3.md), [**kdk\_system\_set\_12\_timeformat**(3)](/man/kdk_system_set_12_timeformat/3.md), [**kdk\_system\_get\_now\_dateformat**(3)](/man/kdk_system_get_now_dateformat/3.md), **kdk\_system\_get\_now\_timeformat**(3), [**kdk\_system\_tran\_dateformat**(3)](/man/kdk_system_tran_dateformat/3.md), [**kdk\_system\_nowtime**(3)](/man/kdk_system_nowtime/3.md), [**kdk\_system\_nowdate**(3)](/man/kdk_system_nowdate/3.md), [**kdk\_system\_shortweek**(3)](/man/kdk_system_shortweek/3.md), [**kdk\_system\_longweek**(3)](/man/kdk_system_longweek/3.md), [**kdk\_system\_second**(3)](/man/kdk_system_second/3.md), [**kdk\_system\_logn\_dateinfo**(3)](/man/kdk_system_logn_dateinfo/3.md), [**kdk\_system\_gjx\_time**(3)](/man/kdk_system_gjx_time/3.md), [**kdk\_date\_freeall**(3)](/man/kdk_date_freeall/3.md), [**kdk\_free\_dateinfo**(3)](/man/kdk_free_dateinfo/3.md), [**kdk\_free\_logn\_dateinfo**(3)](/man/kdk_free_logn_dateinfo/3.md), [**kdk\_system\_set\_long\_dateformat**(3)](/man/kdk_system_set_long_dateformat/3.md), [**kdk\_system\_set\_short\_dateformat**(3)](/man/kdk_system_set_short_dateformat/3.md), [**kdk\_system\_get\_longformat\_date**(3)](/man/kdk_system_get_longformat_date/3.md), [**kdk\_system\_get\_shortformat\_date**(3)](/man/kdk_system_get_shortformat_date/3.md), [**kdk\_system\_get\_longformat**(3)](/man/kdk_system_get_longformat/3.md), [**kdk\_system\_get\_shortformat**(3)](/man/kdk_system_get_shortformat/3.md), [**kdk\_system\_longformat\_transform**(3)](/man/kdk_system_longformat_transform/3.md), **kdk\_system\_shortformat\_transform**(3), [**kdk\_system\_login\_lock\_dateinfo**(3)](/man/kdk_system_login_lock_dateinfo/3.md) and [**kdk\_free\_timeinfo**(3)](/man/kdk_free_timeinfo/3.md).
