Skip to content

Commit

Permalink
Add: documentation for NASL ISO time functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Kraemii committed Dec 19, 2022
1 parent c32044e commit bc2bd4d
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 0 deletions.
9 changes: 9 additions & 0 deletions doc/manual/nasl/built-in-functions/isotime-functions/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ISO time functions

## GENERAL

The ISO time is standardized form for representing time formats from the year 0 to 9999. This family of functions are able to generate and alter given times in such formats, as well as get information about the current time.

In most 32 bit systems a signed 32 bit integer value is used to represent the system time. Unfortunately this only enables the usage of time between 1. January 1970 00:00:00 to 19. January 2038 03:14:07. However for VTs we sometimes need to calculate dates in the future beyond that. For example some certificates are (for whatever reason) valid for 30 years. To solve this problem in a platform independent way, we provide the time as a string and provide functions to work with them.

## TOC
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# isotime_add

## NAME

**isotime_add** - add years, days or seconds to an ISO time string

## SYNOPSIS

*string* **isotime_add**(0: *string*, years: *int*, days: *int*, seconds: *int*);

**isotime_add** takes 1 positional and up to 3 named arguments.

## DESCRIPTION

Adds given years, days and seconds to a given ISO time string.

The first positional argument is a *string* containing an ISO time string.

The named argument *years* is an *int* containing the number of years to add to the ISO time string

The named argument *days* is an *int* containing the number of days to add to the ISO time string

The named argument *seconds* is an *int* containing the number of seconds to add to the ISO time string

## RETURN VALUE

The resulting ISO time as *string* or *NULL* on error

## ERRORS

The first positional argument containing the ISO time string is missing or invalid.

The result would overflow, i.e. year >9999.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# isotime_is_valid

## NAME

**isotime_is_valid** - check if a ISO time string is valid

## SYNOPSIS

*bool* **isotime_is_valid**(0: *string*);

**isotime_is_valid** takes 1 positional argument.

## DESCRIPTION

Checks the validity for a given ISO time string. Valid strings are both the standard 15 byte string (`yyyymmddThhmmss`) and the better human readable up to 19 byte (`yyyy-mm-dd[ hh[:mm[:ss]]]`) are valid.

The first unnamed argument is the *string* to be checked.

## RETURN VALUE

A *bool* either TRUE or FALSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# isotime_now

## NAME

**isotime_now** - get the current time in the standard ISO format

*string* **isotime_now**();

**isotime_now** takes no arguments

## DESCRIPTION

If available get the current time in the standard ISO time format (`yyyymmddThhmmss`).

## RETURN VALUE

The current ISO time as *string* or *NULL* if no time is available.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# isotime_print

## NAME

**isotime_print** - convert ISO time string to a better readable form

*string* **isotime_print**(0: *string*);

**isotime_print** takes one positional argument.

## DESCRIPTION

Convert a standard isotime (`yyyymmddThhmmss`) into the human readable variant (`yyyy-mm-dd hh:mm:ss`).

The first unnamed argument is a *string* containing the string to convert.

## RETURN VALUE

The ISO time in a human readable form as *string* or *NULL* on error.

## ERRORS

First unnamed argument is either missing or in the wrong format.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# isotime_scan

## NAME

**isotime_scan** - convert a string into an ISO time string

*string* **isotime_scan**(0: *string*);

**isotime_scan** takes 1 positional argument.

## DESCRIPTION

Convert a standard isotime (`yyyymmddThhmmss`) or a human readable variant (`yyyy-mm-dd[ hh[:mm[:ss]]]`) into the standard isotime (`yyyymmddThhmmss`).

The first unnamed argument is a *string* containing the string to convert.

## RETURN VALUE

The standard ISO time as *string* or *NULL* on error.

## ERRORS

First unnamed argument is missing.

Given string is too short.

Unable to convert string.

0 comments on commit bc2bd4d

Please sign in to comment.