diff options
| author | 2023-05-31 22:43:20 +0200 | |
|---|---|---|
| committer | 2023-05-31 22:43:20 +0200 | |
| commit | e772950a029d661e6d1f8ec4ea28016a97dbe1df (patch) | |
| tree | 6db55372ec65061e4c62367a51c3c5da6dd829c6 /src | |
| parent | fix JANET_REG on windows (diff) | |
add docs, callables for timegm
Diffstat (limited to 'src')
| -rw-r--r-- | src/time.c | 6 | ||||
| -rw-r--r-- | src/tm.c | 31 |
2 files changed, 22 insertions, 15 deletions
@@ -52,7 +52,7 @@ time_t *jd_maketime(void) { JANET_FN(jd_gmtime, "(gmtime (time))", - "") { + "Convert a date/time object into a date/tm object as UTC.") { janet_fixarity(argc, 1); time_t *time = jd_gettime(argv, 0); struct tm *tm = gmtime(time); @@ -63,7 +63,7 @@ JANET_FN(jd_gmtime, JANET_FN(jd_localtime, "(localtime (time))", - "") { + "Convert a date/time object into a date/tm object as localtime.") { janet_fixarity(argc, 1); time_t *time = jd_gettime(argv, 0); struct tm *tm = localtime(time); @@ -74,7 +74,7 @@ JANET_FN(jd_localtime, JANET_FN(jd_time, "(time)", - "") { + "Get the current moment in time as a date/time object.") { (void) argv; janet_fixarity(argc, 0); time_t *out = jd_maketime(); @@ -7,6 +7,8 @@ static JanetMethod jd_tm_methods[] = { // raw mktime, returning time_t {"mktime", jd_mktime}, {"mktime!", jd_mktime_inplace}, + {"timegm", jd_timegm}, + {"timegm!", jd_timegm_inplace}, {"strftime", jd_strftime}, {NULL, NULL}, }; @@ -213,8 +215,8 @@ struct tm *jd_opttm(Janet *argv, int32_t argc, int32_t n) { } JANET_FN(jd_tm, - "", - "") { + "(tm {:sec 0 ...})", + "Construct a date/tm object from a compatible dictionary.") { janet_fixarity(argc, 1); JanetDictView view = janet_getdictionary(argv, 0); @@ -257,8 +259,8 @@ JANET_FN(jd_tm, } JANET_FN(jd_mktime, - "", - "") { + "(mktime tm)", + "Convert a date/tm object as localtime to a normalized date/time object.") { janet_fixarity(argc, 1); struct tm *tm = jd_gettm(argv, 0); struct tm *nw = jd_maketm(); @@ -269,8 +271,9 @@ JANET_FN(jd_mktime, } JANET_FN(jd_mktime_inplace, - "", - "") { + "(mktime! tm)", + "Convert a date/tm object as localtime to a normalized date/time object.\n" + "The date/tm object will be normalized in-place via mutation.") { janet_fixarity(argc, 1); struct tm *tm = jd_gettm(argv, 0); time_t *time = jd_maketime(); @@ -279,8 +282,8 @@ JANET_FN(jd_mktime_inplace, } JANET_FN(jd_timegm, - "", - "") { + "(timegm tm)", + "Convert a date/tm object as UTC to a normalized date/time object.") { janet_fixarity(argc, 1); struct tm *tm = jd_gettm(argv, 0); struct tm *nw = jd_maketm(); @@ -291,8 +294,9 @@ JANET_FN(jd_timegm, } JANET_FN(jd_timegm_inplace, - "", - "") { + "(timegm! tm)", + "Convert a date/tm object as UTC to a normalized date/time object.\n" + "The date/tm object will be normalized in-place via mutation.") { janet_fixarity(argc, 1); struct tm *tm = jd_gettm(argv, 0); time_t *time = jd_maketime(); @@ -314,8 +318,11 @@ const static struct strftime_format strftime_formats[] = { {NULL, NULL}, }; JANET_FN(jd_strftime, - "", - "") { + "(strftime tm \"%c\")\n" + "(strftime tm :iso8601)", + "Format a string from the date/tm object.\n" + "Has available preset formats.\n" + "Note that some platforms may potentially treat tm as localtime.") { janet_fixarity(argc, 2); // tm is first for pseudo-OO struct tm *tm = jd_gettm(argv, 0); |
