aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/time.c6
-rw-r--r--src/tm.c31
2 files changed, 22 insertions, 15 deletions
diff --git a/src/time.c b/src/time.c
index a94064d..8031e44 100644
--- a/src/time.c
+++ b/src/time.c
@@ -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();
diff --git a/src/tm.c b/src/tm.c
index f263167..f77bef4 100644
--- a/src/tm.c
+++ b/src/tm.c
@@ -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);