Skip to content

Commit

Permalink
new_token() no longer accept int, float and str as time
Browse files Browse the repository at this point in the history
  • Loading branch information
joente committed Jan 23, 2024
1 parent 415154c commit 6c688aa
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 49 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
`pow(..)`, `sin(..)`, `sqrt(..)` and `tan(..)`.
* Added mathematical constants `MATH_E` and `MATH_PI` with corresponding values.
* libcleri is now integrated into the core ThingsDB codebase, eliminating the need for separate installation.
* The `new_backup()` function no longer accepts an `int`, `float` or `str` as start time.
* The `new_backup()` and `new_token()` functions no longer accept `int`, `float` or `str` as time.
_(This was marked as deprecated since v0.10.1)_

# v1.4.16
Expand Down
46 changes: 0 additions & 46 deletions inc/ti/fn/fnnewtoken.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,51 +60,6 @@ static int do__f_new_token(ti_query_t * query, cleri_node_t * nd, ex_t * e)

exp_time = (uint64_t) ts;
}
else if (ti_val_is_float(query->rval))
{
log_warning(
"parsing type `float` to `new_token(..)` as second argument "
"is obsolete, use type `datetime` or type `timeval` instead");
double now = util_now();
double ts = VFLOAT(query->rval);
if (ts < now)
goto errpast;
if (ts > TI_MAX_EXPIRATION_DOUBLE)
goto errfuture;

exp_time = (uint64_t) ts;
}
else if (ti_val_is_int(query->rval))
{
log_warning(
"parsing type `int` to `new_token(..)` as second argument "
"is obsolete, use type `datetime` or type `timeval` instead");
int64_t now = (int64_t) util_now_usec();
int64_t ts = VINT(query->rval);
if (ts < now)
goto errpast;
if (ts > TI_MAX_EXPIRATION_LONG)
goto errfuture;

exp_time = (uint64_t) ts;
}
else if (ti_val_is_str(query->rval))
{
log_warning(
"parsing type `str` to `new_token(..)` as second argument "
"is obsolete, use type `datetime` or type `timeval` instead");
int64_t now = (int64_t) util_now_usec();
ti_raw_t * rt = (ti_raw_t *) query->rval;
int64_t ts = iso8601_parse_date_n((const char *) rt->data, rt->n);
if (ts < 0)
goto errinvalid;
if (ts < now)
goto errpast;
if (ts > TI_MAX_EXPIRATION_LONG)
goto errfuture;

exp_time = (uint64_t) ts;
}
else if (!ti_val_is_nil(query->rval))
{
ex_set(e, EX_TYPE_ERROR,
Expand All @@ -114,7 +69,6 @@ static int do__f_new_token(ti_query_t * query, cleri_node_t * nd, ex_t * e)
ti_val_str(query->rval));
return e->nr;
}

}

if (nargs > 2)
Expand Down
2 changes: 1 addition & 1 deletion inc/ti/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* "-rc0"
* ""
*/
#define TI_VERSION_PRE_RELEASE "-alpha6"
#define TI_VERSION_PRE_RELEASE "-alpha7"

#define TI_MAINTAINER \
"Jeroen van der Heijden <jeroen@cesbit.com>"
Expand Down
2 changes: 1 addition & 1 deletion src/cleri/ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ void cleri_ref_set(cleri_t * ref, cleri_t * cl_obj)
*/
static void ref__free(cleri_t * cl_object __attribute__((unused)))
{
/* nothing todo */
/* nothing, this just must exist */
}

0 comments on commit 6c688aa

Please sign in to comment.