NAME
parse_date - parses a date string into a timespec struct.
SYNOPSIS
#include "timeutils.h"
int parse_date(struct timespec *result, char const *p,
struct timespec const *now)
LDADD libcommon.la
DESCRIPTION
Parse a date/time string, storing the resulting time value into *result.
The string itself is pointed to by *p. Return 1 if successful.
*p can be an incomplete or relative time specification; if so, use
*now as the basis for the returned time.
This function is based upon gnulib's parse-datetime.y-dd7a871.
Below is a plain text version of the gnulib parse-datetime.texi-dd7a871 manual
describing the input strings that are recognized.
Any future modifications to the util-linux parser that affect input strings
should be noted below.
1 Date input formats
********************
First, a quote:
Our units of temporal measurement, from seconds on up to months,
are so complicated, asymmetrical and disjunctive so as to make
coherent mental reckoning in time all but impossible. Indeed, had
some tyrannical god contrived to enslave our minds to time, to
make it all but impossible for us to escape subjection to sodden
routines and unpleasant surprises, he could hardly have done
better than handing down our present system. It is like a set of
trapezoidal building blocks, with no vertical or horizontal
surfaces, like a language in which the simplest thought demands
ornate constructions, useless particles and lengthy
circumlocutions. Unlike the more successful patterns of language
and science, which enable us to face experience boldly or at least
level-headedly, our system of temporal calculation silently and
persistently encourages our terror of time.
... It is as though architects had to measure length in feet,
width in meters and height in ells; as though basic instruction
manuals demanded a knowledge of five different languages. It is
no wonder then that we often look into our own immediate past or
future, last Tuesday or a week from Sunday, with feelings of
helpless confusion. ...
--Robert Grudin, `Time and the Art of Living'.
This section describes the textual date representations that GNU
programs accept. These are the strings you, as a user, can supply as
arguments to the various programs. The C interface (via the
`parse_datetime' function) is not described here.
1.1 General date syntax
=======================
A "date" is a string, possibly empty, containing many items separated
by whitespace. The whitespace may be omitted when no ambiguity arises.
The empty string means the beginning of today (i.e., midnight). Order
of the items is immaterial. A date string may contain many flavors of
items:
* calendar date items
* time of day items
* time zone items
* combined date and time of day items
* day of the week items
* relative items
* pure numbers.
We describe each of these item types in turn, below.
A few ordinal numbers may be written out in words in some contexts.
This is most useful for specifying day of the week items or relative
items (see below). Among the most commonly used ordinal numbers, the
word `last' stands for -1, `this' stands for 0, and `first' and `next'
both stand for 1. Because the word `second' stands for the unit of
time there is no way to write the ordinal number 2, but for convenience
`third' stands for 3, `fourth' for 4, `fifth' for 5, `sixth' for 6,
`seventh' for 7, `eighth' for 8, `ninth' for 9, `tenth' for 10,
`eleventh' for 11 and `twelfth' for 12.
When a month is written this way, it is still considered to be
written numerically, instead of being "spelled in full"; this changes
the allowed strings.
In the current implementation, only English is supported for words
and abbreviations like `AM', `DST', `EST', `first', `January',
`Sunday', `tomorrow', and `year'.
The output of the `date' command is not always acceptable as a date
string, not only because of the language problem, but also because
there is no standard meaning for time zone items like `IST'. When using
`date' to generate a date string intended to be parsed later, specify a
date format that is independent of language and that does not use time
zone items other than `UTC' and `Z'. Here are some ways to do this:
$ LC_ALL=C TZ=UTC0 date
Mon Mar 1 00:21:42 UTC 2004
$ TZ=UTC0 date +'%Y-%m-%d %H:%M:%SZ'
2004-03-01 00:21:42Z
$ date --rfc-3339=ns # --rfc-3339 is a GNU extension.
2004-02-29 16:21:42.692722128-08:00
$ date --rfc-2822 # a GNU extension
Sun, 29 Feb 2004 16:21:42 -0800
$ date +'%Y-%m-%d %H:%M:%S %z' # %z is a GNU extension.
2004-02-29 16:21:42 -0800
$ date +'@%s.%N' # %s and %N are GNU extensions.
@1078100502.692722128
Alphabetic case is completely ignored in dates. Comments may be
introduced between round parentheses, as long as included parentheses
are properly nested. Hyphens not followed by a digit are currently
ignored. Leading zeros on numbers are ignored.
Invalid dates like `2005-02-29' or times like `24:00' are rejected.
In the typical case of a host that does not support leap seconds, a
time like `23:59:60' is rejected even if it corresponds to a valid leap
second.
1.2 Calendar date items
=======================
A "calendar date item" specifies a day of the year. It is specified
differently, depending on whether the month is specified numerically or
literally. All these strings specify the same calendar date:
1972-09-24 # ISO 8601.
72-9-24 # Assume 19xx for 69 through 99,
# 20xx for 00 through 68.
72-09-24 # Leading zeros are ignored.
9/24/72 # Common U.S. writing.
24 September 1972
24 Sept 72 # September has a special abbreviation.
24 Sep 72 # Three-letter abbreviations always allowed.
Sep 24, 1972
24-sep-72
24sep72
The year can also be omitted. In this case, the last specified year
is used, or the current year if none. For example:
9/24
sep 24
Here are the rules.
For numeric months, the ISO 8601 format `YEAR-MONTH-DAY' is allowed,
where YEAR is any positive number, MONTH is a number between 01 and 12,
and DAY is a number between 01 and 31. A leading zero must be present
if a number is less than ten. If YEAR is 68 or smaller, then 2000 is
added to it; otherwise, if YEAR is less than 100, then 1900 is added to
it. The construct `MONTH/DAY/YEAR', popular in the United States, is
accepted. Also `MONTH/DAY', omitting the year.
Literal months may be spelled out in full: `January', `February',
`March', `April', `May', `June', `July', `August', `September',
`October', `November' or `December'. Literal months may be abbreviated
to their first three letters, possibly followed by an abbreviating dot.
It is also permitted to write `Sept' instead of `September'.
When months are written literally, the calendar date may be given as
any of the following:
DAY MONTH YEAR
DAY MONTH
MONTH DAY YEAR
DAY-MONTH-YEAR
Or, omitting the year:
MONTH DAY
1.3 Time of day items
=====================
A "time of day item" in date strings specifies the time on a given day.
Here are some examples, all of which represent the same time:
20:02:00.000000
20:02
8:02pm
20:02-0500 # In EST (U.S. Eastern Standard Time).
More generally, the time of day may be given as
`HOUR:MINUTE:SECOND', where HOUR is a number between 0 and 23, MINUTE
is a number between 0 and 59, and SECOND is a number between 0 and 59
possibly followed by `.' or `,' and a fraction containing one or more
digits. Alternatively, `:SECOND' can be omitted, in which case it is
taken to be zero. On the rare hosts that support leap seconds, SECOND
may be 60.
If the time is followed by `am' or `pm' (or `a.m.' or `p.m.'), HOUR
is restricted to run from 1 to 12
没有合适的资源?快使用搜索试试~ 我知道了~
Linux 中util-linux 工具包的源码
需积分: 0 1 下载量 51 浏览量
2023-10-20
14:25:31
上传
评论
收藏 17.42MB GZ 举报
温馨提示
共2000个文件
c:420个
h:118个
err:104个
Linux 中util-linux 工具包的源码,可用于交叉编译,里面包含hwclock等Linux命令的完整版,busybox里面系统自带的命令是阉割版,这里的是完整版本
资源推荐
资源详情
资源评论
收起资源包目录
Linux 中util-linux 工具包的源码 (2000个子文件)
low-probe-udf-hdd-mkudffs-1.0.0-1 386B
low-probe-udf-hdd-mkudffs-1.0.0-2 407B
COPYING.GPL-3.0-or-later 34KB
COPYING.GPL-2.0-or-later 18KB
lsfd.1 21KB
unshare.1 19KB
getopt.1 15KB
logger.1 14KB
dmesg.1 10KB
login.1 10KB
setterm.1 10KB
cal.1 10KB
su.1 9KB
nsenter.1 9KB
script.1 9KB
hardlink.1 9KB
runuser.1 8KB
setpriv.1 8KB
lscpu.1 8KB
eject.1 8KB
pipesz.1 8KB
kill.1 7KB
flock.1 7KB
lslogins.1 7KB
fallocate.1 6KB
last.1 6KB
scriptreplay.1 5KB
prlimit.1 5KB
lsmem.1 5KB
whereis.1 5KB
lsipc.1 5KB
rename.1 4KB
ipcs.1 4KB
renice.1 4KB
ipcrm.1 4KB
chfn.1 4KB
uuidgen.1 4KB
scriptlive.1 4KB
choom.1 4KB
namei.1 3KB
look.1 3KB
irqtop.1 3KB
fincore.1 3KB
mesg.1 3KB
write.1 3KB
utmpdump.1 3KB
wall.1 3KB
uuidparse.1 3KB
mcookie.1 3KB
chsh.1 3KB
mountpoint.1 2KB
fadvise.1 2KB
lsirq.1 2KB
ipcmk.1 2KB
waitpid.1 2KB
setsid.1 2KB
newgrp.1 2KB
lastb.1 10B
COPYING.LGPL-2.1-or-later 26KB
v2.39.1-ReleaseNotes 5KB
v2.13-ReleaseNotes 21KB
v2.14-ReleaseNotes 18KB
v2.15-ReleaseNotes 29KB
v2.16-ReleaseNotes 8KB
v2.17-ReleaseNotes 22KB
v2.18-ReleaseNotes 21KB
v2.19-ReleaseNotes 29KB
v2.20-ReleaseNotes 48KB
v2.21-ReleaseNotes 45KB
v2.22-ReleaseNotes 54KB
v2.23-ReleaseNotes 54KB
v2.24-ReleaseNotes 44KB
v2.25-ReleaseNotes 61KB
v2.26-ReleaseNotes 51KB
v2.27-ReleaseNotes 35KB
v2.28-ReleaseNotes 33KB
v2.29-ReleaseNotes 26KB
libblkid.3 7KB
uuid_generate.3 5KB
uuid_parse.3 2KB
uuid_unparse.3 2KB
uuid_time.3 2KB
uuid.3 2KB
uuid_is_null.3 1KB
uuid_compare.3 1KB
uuid_copy.3 1KB
uuid_clear.3 1KB
uuid_generate_time.3 19B
uuid_generate_time_safe.3 19B
uuid_generate_random.3 19B
low-probe-udf-hdd-mkudffs-1.3-1 378B
low-probe-udf-hdd-mkudffs-1.3-2 380B
low-probe-udf-hdd-mkudffs-1.3-4 380B
low-probe-udf-hdd-mkudffs-1.3-6 478B
low-probe-udf-hdd-mkudffs-1.3-7 396B
low-probe-udf-hdd-mkudffs-1.3-8 390B
v2.30-ReleaseNotes 34KB
v2.31-ReleaseNotes 31KB
dump-v2.32 2KB
v2.32-ReleaseNotes 21KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
海边的淡水鱼zz
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功