KDK_SYSTEM_SECOND(3)

📦 version 3.0.1.4, in arch rolling, ubuntu resolute, ubuntu stonking

💖 NAME 💖

okay so bestie, say hi to kdk_system_second — the 获取当前秒钟接口 (aka "the get-the-current-second interface", for the non-Chinese speakers in the group chat 🫶). She has one job and she does it, periodt.

she's a library function, so she lives in section 3, the Library Functions Manual. 💅


🌸 SYNOPSIS 🌸

#include <libkydate.h>

extern char* kdk_system_second();

and bestie, when you build, you link with -lkydate or she simply will not show up. no cap. 🔥


✨ DETAILED DESCRIPTION ✨

The main function of this interface is to obtain the current second. that's it. that's the whole personality. no side quests, no drama, just gimme the second and she delivers. ✨


🎀 RETURN VALUE 🎀

  • on success — she hands you the current second as a char*. and listen, the returned string needs to be released by free. do not ghost it. do not leave it on read. your memory will leak and that's not the vibe. 😭
  • on error — she returns NULL. that's her way of saying "not today". 💀

🧚 EXAMPLES 🧚

here's the whole little demo, copied exactly so you can steal it wholesale 🍓:

#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. (withdrawn, bestie — so, like, historically iconic but no longer the moment. 🫠)

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_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(), kdk_system_timeformat_transform() and kdk_free_timeinfo().


🌈 SEE ALSO 🌈

the whole friend group, go say hi 💜:

kdk_system_get_dateformat(3), kdk_system_set_dateformat(3), kdk_system_set_24_timeformat(3), kdk_system_set_12_timeformat(3), kdk_system_get_now_dateformat(3), kdk_system_get_now_timeformat(3), kdk_system_tran_dateformat(3), kdk_system_nowtime(3), kdk_system_nowdate(3), kdk_system_shortweek(3), kdk_system_longweek(3), kdk_system_logn_dateinfo(3), kdk_system_gjx_time(3), kdk_date_freeall(3), kdk_free_dateinfo(3), kdk_free_logn_dateinfo(3), kdk_system_set_long_dateformat(3), kdk_system_set_short_dateformat(3), kdk_system_get_longformat_date(3), kdk_system_get_shortformat_date(3), kdk_system_get_longformat(3), kdk_system_get_shortformat(3), kdk_system_longformat_transform(3), kdk_system_shortformat_transform(3), kdk_system_login_lock_dateinfo(3), kdk_system_timeformat_transform(3) and kdk_free_timeinfo(3).


mwah, love u, bye 💋 this page came to you straight from the Linux Programmer's Manual, dated Tue Sep 19 2023, and its whole name-and-number is KDK_SYSTEM_SECOND(3). screenshotted, saved, and slaying in the group chat forever. 🎀✨

📦 where this page comes from