kdk_system_set_dateformat3
设置日期格式
Usage
#include <libkydate.h> extern int kdk_system_set_dateformat(char *date); Link with -lkydate.
Detailed Description
The main function of this interface is to set the date format of the system.
The argument date is the date format, Please refer to the return value of kdk_system_get_format for specific format.
Return value
On success, returns 1
On error, return -1.
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;
}