diff options
author | Cy Schubert <cy@FreeBSD.org> | 2023-01-06 20:48:22 +0000 |
---|---|---|
committer | Cy Schubert <cy@FreeBSD.org> | 2023-01-06 20:48:22 +0000 |
commit | 6f4e10db3298f6d65e1e646fe52aaafc3682b788 (patch) | |
tree | 0a8de0ec1173c00886bcde1c3b18e0963e5f2b83 /lib/roken/parse_time.cat3 | |
parent | d5d1e8b157da7410fe13e6302f8e1bee81320bb5 (diff) |
Diffstat (limited to 'lib/roken/parse_time.cat3')
-rw-r--r-- | lib/roken/parse_time.cat3 | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/lib/roken/parse_time.cat3 b/lib/roken/parse_time.cat3 index ca1c51ff4916..5aab1da9ca05 100644 --- a/lib/roken/parse_time.cat3 +++ b/lib/roken/parse_time.cat3 @@ -1,40 +1,39 @@ - PARSE_TIME(3) BSD Library Functions Manual PARSE_TIME(3) -NNAAMMEE - ppaarrssee__ttiimmee, pprriinntt__ttiimmee__ttaabbllee, uunnppaarrssee__ttiimmee, uunnppaarrssee__ttiimmee__aapppprrooxx, -- parse +[1mNAME[0m + [1mparse_time[22m, [1mprint_time_table[22m, [1munparse_time[22m, [1munparse_time_approx[22m, -- parse and unparse time intervals -LLIIBBRRAARRYY +[1mLIBRARY[0m The roken library (libroken, -lroken) -SSYYNNOOPPSSIISS - ##iinncclluuddee <<ppaarrssee__ttiimmee..hh>> +[1mSYNOPSIS[0m + [1m#include <parse_time.h>[0m - _i_n_t - ppaarrssee__ttiimmee(_c_o_n_s_t _c_h_a_r _*_t_i_m_e_s_p_e_c, _c_o_n_s_t _c_h_a_r _*_d_e_f___u_n_i_t); + [4mint[0m + [1mparse_time[22m([4mconst[24m [4mchar[24m [4m*timespec[24m, [4mconst[24m [4mchar[24m [4m*def_unit[24m); - _v_o_i_d - pprriinntt__ttiimmee__ttaabbllee(_F_I_L_E _*_f); + [4mvoid[0m + [1mprint_time_table[22m([4mFILE[24m [4m*f[24m); - _s_i_z_e___t - uunnppaarrssee__ttiimmee(_i_n_t _s_e_c_o_n_d_s, _c_h_a_r _*_b_u_f, _s_i_z_e___t _l_e_n); + [4msize_t[0m + [1munparse_time[22m([4mint[24m [4mseconds[24m, [4mchar[24m [4m*buf[24m, [4msize_t[24m [4mlen[24m); - _s_i_z_e___t - uunnppaarrssee__ttiimmee__aapppprrooxx(_i_n_t _s_e_c_o_n_d_s, _c_h_a_r _*_b_u_f, _s_i_z_e___t _l_e_n); + [4msize_t[0m + [1munparse_time_approx[22m([4mint[24m [4mseconds[24m, [4mchar[24m [4m*buf[24m, [4msize_t[24m [4mlen[24m); -DDEESSCCRRIIPPTTIIOONN - The ppaarrssee__ttiimmee() function converts the period of time specified into a - number of seconds. The _t_i_m_e_s_p_e_c can be any number of <number unit> pairs +[1mDESCRIPTION[0m + The [1mparse_time[22m() function converts the period of time specified into a + number of seconds. The [4mtimespec[24m can be any number of <number unit> pairs separated by comma and whitespace. The number can be negative. Numbers - without explicit units are taken as being _d_e_f___u_n_i_t. + without explicit units are taken as being [4mdef_unit[24m. - The uunnppaarrssee__ttiimmee() and uunnppaarrssee__ttiimmee__aapppprrooxx() do the opposite of - ppaarrssee__ttiimmee(), that is they take a number of seconds and express that as - human readable strings. _u_n_p_a_r_s_e___t_i_m_e produces an exact time, while - _u_n_p_a_r_s_e___t_i_m_e___a_p_p_r_o_x restricts the result to include only one unit. + The [1munparse_time[22m() and [1munparse_time_approx[22m() do the opposite of + [1mparse_time[22m(), that is they take a number of seconds and express that as + human readable strings. [4munparse_time[24m produces an exact time, while + [4munparse_time_approx[24m restricts the result to include only one unit. - pprriinntt__ttiimmee__ttaabbllee() prints a descriptive list of available units on the + [1mprint_time_table[22m() prints a descriptive list of available units on the passed file descriptor. The possible units include: @@ -48,14 +47,14 @@ DDEESSCCRRIIPPTTIIOONN Units names can be arbitrarily abbreviated (as long as they are unique). -RREETTUURRNN VVAALLUUEESS - ppaarrssee__ttiimmee() returns the number of seconds that represents the expression - in _t_i_m_e_s_p_e_c or -1 on error. uunnppaarrssee__ttiimmee() and uunnppaarrssee__ttiimmee__aapppprrooxx() - return the number of characters written to _b_u_f. if the return value is - greater than or equal to the _l_e_n argument, the string was too short and +[1mRETURN VALUES[0m + [1mparse_time[22m() returns the number of seconds that represents the expression + in [4mtimespec[24m or -1 on error. [1munparse_time[22m() and [1munparse_time_approx[22m() re- + turn the number of characters written to [4mbuf[24m. if the return value is + greater than or equal to the [4mlen[24m argument, the string was too short and some of the printed characters were discarded. -EEXXAAMMPPLLEESS +[1mEXAMPLES[0m #include <stdio.h> #include <parse_time.h> @@ -103,8 +102,8 @@ EEXXAAMMPPLLEESS unparse_time = 12 months 4 days 23 hours 59 minutes 59 seconds unparse_time_approx = 12 months -BBUUGGSS - Since ppaarrssee__ttiimmee() returns -1 on error there is no way to parse "minus +[1mBUGS[0m + Since [1mparse_time[22m() returns -1 on error there is no way to parse "minus one second". Currently "s" at the end of units is ignored. This is a hack for English plural forms. If these functions are ever localised, this scheme will have to change. |