1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-24 17:27:18 +00:00

Update CHANGELOG.

and format.
This commit is contained in:
Calvin Rose 2023-05-11 18:03:38 -05:00
parent bcbeedb001
commit 84a4e3e98a
3 changed files with 18 additions and 18 deletions

View File

@ -2,6 +2,7 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
## Unreleased - ??? ## Unreleased - ???
- Add `os/strftime` for date formatting.
- Fix `ev/select` on threaded channels sometimes live-locking. - Fix `ev/select` on threaded channels sometimes live-locking.
- Support the `NO_COLOR` environment variable to turn off VT100 color codes in repl (and in scripts). - Support the `NO_COLOR` environment variable to turn off VT100 color codes in repl (and in scripts).
See http://no-color.org/ See http://no-color.org/

View File

@ -1013,15 +1013,15 @@ static void chan_unlock_args(const Janet *argv, int32_t n) {
JANET_CORE_FN(cfun_channel_choice, JANET_CORE_FN(cfun_channel_choice,
"(ev/select & clauses)", "(ev/select & clauses)",
"Block until the first of several channel operations occur. Returns a " "Block until the first of several channel operations occur. Returns a "
"tuple of the form [:give chan], [:take chan x], or [:close chan], " "tuple of the form [:give chan], [:take chan x], or [:close chan], "
"where a :give tuple is the result of a write and a :take tuple is the " "where a :give tuple is the result of a write and a :take tuple is the "
"result of a read. Each clause must be either a channel (for a channel " "result of a read. Each clause must be either a channel (for a channel "
"take operation) or a tuple [channel x] (for a channel give operation). " "take operation) or a tuple [channel x] (for a channel give operation). "
"Operations are tried in order such that earlier clauses take " "Operations are tried in order such that earlier clauses take "
"precedence over later clauses. Both give and take operations can " "precedence over later clauses. Both give and take operations can "
"return a [:close chan] tuple, which indicates that the specified " "return a [:close chan] tuple, which indicates that the specified "
"channel was closed while waiting, or that the channel was already " "channel was closed while waiting, or that the channel was already "
"closed.") { "closed.") {
janet_arity(argc, 1, -1); janet_arity(argc, 1, -1);
int32_t len; int32_t len;
const Janet *data; const Janet *data;

View File

@ -1354,8 +1354,7 @@ JANET_CORE_FN(os_cryptorand,
/* Helper function to get given or current time as local or UTC struct tm. /* Helper function to get given or current time as local or UTC struct tm.
* - arg n+0: optional time_t to be converted, uses current time if not given * - arg n+0: optional time_t to be converted, uses current time if not given
* - arg n+1: optional truthy to indicate the convnersion uses local time */ * - arg n+1: optional truthy to indicate the convnersion uses local time */
static struct tm *time_to_tm(const Janet *argv, int32_t argc, int32_t n, struct tm *t_infos) static struct tm *time_to_tm(const Janet *argv, int32_t argc, int32_t n, struct tm *t_infos) {
{
time_t t; time_t t;
if (argc > n && !janet_checktype(argv[n], JANET_NIL)) { if (argc > n && !janet_checktype(argv[n], JANET_NIL)) {
int64_t integer = janet_getinteger64(argv, n); int64_t integer = janet_getinteger64(argv, n);
@ -1364,7 +1363,7 @@ static struct tm *time_to_tm(const Janet *argv, int32_t argc, int32_t n, struct
time(&t); time(&t);
} }
struct tm *t_info = NULL; struct tm *t_info = NULL;
if (argc > n+1 && janet_truthy(argv[n+1])) { if (argc > n + 1 && janet_truthy(argv[n + 1])) {
/* local time */ /* local time */
#ifdef JANET_WINDOWS #ifdef JANET_WINDOWS
_tzset(); _tzset();
@ -1421,11 +1420,11 @@ JANET_CORE_FN(os_date,
#define SIZETIMEFMT 250 #define SIZETIMEFMT 250
JANET_CORE_FN(os_strftime, JANET_CORE_FN(os_strftime,
"(os/strftime fmt &opt time local)", "(os/strftime fmt &opt time local)",
"Format the given time as a string, or the current time if `time` is not given. " "Format the given time as a string, or the current time if `time` is not given. "
"The time is formatted according to the same rules as the ISO C89 function strftime(). " "The time is formatted according to the same rules as the ISO C89 function strftime(). "
"The time is formatted in UTC unless `local` is truthy, in which case the date is formatted for " "The time is formatted in UTC unless `local` is truthy, in which case the date is formatted for "
"the local timezone.") { "the local timezone.") {
janet_arity(argc, 1, 3); janet_arity(argc, 1, 3);
const char *fmt = janet_getcstring(argv, 0); const char *fmt = janet_getcstring(argv, 0);
/* ANSI X3.159-1989, section 4.12.3.5 "The strftime function" */ /* ANSI X3.159-1989, section 4.12.3.5 "The strftime function" */
@ -1433,7 +1432,7 @@ JANET_CORE_FN(os_strftime,
const char *p = fmt; const char *p = fmt;
while (*p) { while (*p) {
if (*p++ == '%') { if (*p++ == '%') {
if(!strchr(valid, *p)) { if (!strchr(valid, *p)) {
janet_panicf("invalid conversion specifier '%%%c'", *p); janet_panicf("invalid conversion specifier '%%%c'", *p);
} }
p++; p++;