getdate.texi

来自「gnu tar 源码包。 tar 软件是 Unix 系统下的一个打包软件」· TEXI 代码 · 共 554 行 · 第 1/2 页

TEXI
554
字号
Either @samp{am}/@samp{pm} or a time zone correction may be specified,but not both.@node Time zone items@section Time zone items@cindex time zone itemA @dfn{time zone item} specifies an international time zone, indicatedby a small set of letters, e.g., @samp{UTC} or @samp{Z}for Coordinated UniversalTime.  Any included periods are ignored.  By following anon-daylight-saving time zone by the string @samp{DST} in a separateword (that is, separated by some white space), the correspondingdaylight saving time zone may be specified.Alternatively, a non-daylight-saving time zone can be followed by atime zone correction, to add the two values.  This is normally doneonly for @samp{UTC}; for example, @samp{UTC+05:30} is equivalent to@samp{+05:30}.Time zone items other than @samp{UTC} and @samp{Z}are obsolescent and are not recommended, because theyare ambiguous; for example, @samp{EST} has a different meaning inAustralia than in the United States.  Instead, it's better to useunambiguous numeric time zone corrections like @samp{-0500}, asdescribed in the previous section.If neither a time zone item nor a time zone correction is supplied,time stamps are interpreted using the rules of the default time zone(@pxref{Specifying time zone rules}).@node Day of week items@section Day of week items@cindex day of week itemThe explicit mention of a day of the week will forward the date(only if necessary) to reach that day of the week in the future.Days of the week may be spelled out in full: @samp{Sunday},@samp{Monday}, @samp{Tuesday}, @samp{Wednesday}, @samp{Thursday},@samp{Friday} or @samp{Saturday}.  Days may be abbreviated to theirfirst three letters, optionally followed by a period.  The specialabbreviations @samp{Tues} for @samp{Tuesday}, @samp{Wednes} for@samp{Wednesday} and @samp{Thur} or @samp{Thurs} for @samp{Thursday} arealso allowed.@findex next @var{day}@findex last @var{day}A number may precede a day of the week item to move forwardsupplementary weeks.  It is best used in expression like @samp{thirdmonday}.  In this context, @samp{last @var{day}} or @samp{next@var{day}} is also acceptable; they move one week before or afterthe day that @var{day} by itself would represent.A comma following a day of the week item is ignored.@node Relative items in date strings@section Relative items in date strings@cindex relative items in date strings@cindex displacement of dates@dfn{Relative items} adjust a date (or the current date if none) forwardor backward.  The effects of relative items accumulate.  Here are someexamples:@example1 year1 year ago3 years2 days@end example@findex year @r{in date strings}@findex month @r{in date strings}@findex fortnight @r{in date strings}@findex week @r{in date strings}@findex day @r{in date strings}@findex hour @r{in date strings}@findex minute @r{in date strings}The unit of time displacement may be selected by the string @samp{year}or @samp{month} for moving by whole years or months.  These are fuzzyunits, as years and months are not all of equal duration.  More preciseunits are @samp{fortnight} which is worth 14 days, @samp{week} worth 7days, @samp{day} worth 24 hours, @samp{hour} worth 60 minutes,@samp{minute} or @samp{min} worth 60 seconds, and @samp{second} or@samp{sec} worth one second.  An @samp{s} suffix on these units isaccepted and ignored.@findex ago @r{in date strings}The unit of time may be preceded by a multiplier, given as an optionallysigned number.  Unsigned numbers are taken as positively signed.  Nonumber at all implies 1 for a multiplier.  Following a relative item bythe string @samp{ago} is equivalent to preceding the unit by amultiplier with value @math{-1}.@findex day @r{in date strings}@findex tomorrow @r{in date strings}@findex yesterday @r{in date strings}The string @samp{tomorrow} is worth one day in the future (equivalentto @samp{day}), the string @samp{yesterday} is worthone day in the past (equivalent to @samp{day ago}).@findex now @r{in date strings}@findex today @r{in date strings}@findex this @r{in date strings}The strings @samp{now} or @samp{today} are relative items correspondingto zero-valued time displacement, these strings come from the facta zero-valued time displacement represents the current time when nototherwise changed by previous items.  They may be used to stress otheritems, like in @samp{12:00 today}.  The string @samp{this} also hasthe meaning of a zero-valued time displacement, but is preferred indate strings like @samp{this thursday}.When a relative item causes the resulting date to cross a boundarywhere the clocks were adjusted, typically for daylight saving time,the resulting date and time are adjusted accordingly.The fuzz in units can cause problems with relative items.  Forexample, @samp{2003-07-31 -1 month} might evaluate to 2003-07-01,because 2003-06-31 is an invalid date.  To determine the previousmonth more reliably, you can ask for the month before the 15th of thecurrent month.  For example:@example$ date -RThu, 31 Jul 2003 13:02:39 -0700$ date --date='-1 month' +'Last month was %B?'Last month was July?$ date --date="$(date +%Y-%m-15) -1 month" +'Last month was %B!'Last month was June!@end exampleAlso, take care when manipulating dates around clock changes such asdaylight saving leaps.  In a few cases these have added or subtractedas much as 24 hours from the clock, so it is often wise to adoptuniversal time by setting the @env{TZ} environment variable to@samp{UTC0} before embarking on calendrical calculations.@node Pure numbers in date strings@section Pure numbers in date strings@cindex pure numbers in date stringsThe precise interpretation of a pure decimal number dependson the context in the date string.If the decimal number is of the form @var{yyyy}@var{mm}@var{dd} and noother calendar date item (@pxref{Calendar date items}) appears before itin the date string, then @var{yyyy} is read as the year, @var{mm} as themonth number and @var{dd} as the day of the month, for the specifiedcalendar date.If the decimal number is of the form @var{hh}@var{mm} and no other timeof day item appears before it in the date string, then @var{hh} is readas the hour of the day and @var{mm} as the minute of the hour, for thespecified time of day.  @var{mm} can also be omitted.If both a calendar date and a time of day appear to the left of a numberin the date string, but no relative item, then the number overrides theyear.@node Seconds since the Epoch@section Seconds since the EpochIf you precede a number with @samp{@@}, it represents an internal timestamp as a count of seconds.  The number can contain an internaldecimal point (either @samp{.} or @samp{,}); any excess precision notsupported by the internal representation is truncated toward minusinfinity.  Such a number cannot be combined with any other dateitem, as it specifies a complete time stamp.@cindex beginning of time, for @acronym{POSIX}@cindex epoch, for @acronym{POSIX}Internally, computer times are represented as a count of seconds sincean epoch---a well-defined point of time.  On @acronym{GNU} and@acronym{POSIX} systems, the epoch is 1970-01-01 00:00:00 @sc{utc}, so@samp{@@0} represents this time, @samp{@@1} represents 1970-01-0100:00:01 @sc{utc}, and so forth.  @acronym{GNU} and most other@acronym{POSIX}-compliant systems support such times as an extensionto @acronym{POSIX}, using negative counts, so that @samp{@@-1}represents 1969-12-31 23:59:59 @sc{utc}.Traditional Unix systems count seconds with 32-bit two's-complementintegers and can represent times from 1901-12-13 20:45:52 through2038-01-19 03:14:07 @sc{utc}.  More modern systems use 64-bit countsof seconds with nanosecond subcounts, and can represent all the timesin the known lifetime of the universe to a resolution of 1 nanosecond.On most hosts, these counts ignore the presence of leap seconds.For example, on most hosts @samp{@@915148799} represents 1998-12-3123:59:59 @sc{utc}, @samp{@@915148800} represents 1999-01-01 00:00:00@sc{utc}, and there is no way to represent the intervening leap second1998-12-31 23:59:60 @sc{utc}.@node Specifying time zone rules@section Specifying time zone rules@vindex TZNormally, dates are interpreted using the rules of the current timezone, which in turn are specified by the @env{TZ} environmentvariable, or by a system default if @env{TZ} is not set.  To specify adifferent set of default time zone rules that apply just to one date,start the date with a string of the form @samp{TZ="@var{rule}"}.  Thetwo quote characters (@samp{"}) must be present in the date, and anyquotes or backslashes within @var{rule} must be escaped by abackslash.For example, with the @acronym{GNU} @command{date} command you cananswer the question ``What time is it in New York when a Paris clockshows 6:30am on October 31, 2004?'' by using a date beginning with@samp{TZ="Europe/Paris"} as shown in the following shell transcript:@example$ export TZ="America/New_York"$ date --date='TZ="Europe/Paris" 2004-10-31 06:30'Sun Oct 31 01:30:00 EDT 2004@end exampleIn this example, the @option{--date} operand begins with its own@env{TZ} setting, so the rest of that operand is processed accordingto @samp{Europe/Paris} rules, treating the string @samp{2004-10-3106:30} as if it were in Paris.  However, since the output of the@command{date} command is processed according to the overall time zonerules, it uses New York time.  (Paris was normally six hours ahead ofNew York in 2004, but this example refers to a brief Halloween periodwhen the gap was five hours.)A @env{TZ} value is a rule that typically names a location in the@uref{http://www.twinsun.com/tz/tz-link.htm, @samp{tz} database}.A recent catalog of location names appears in the@uref{http://twiki.org/cgi-bin/xtra/tzdate, TWiki Date and TimeGateway}.  A few non-@acronym{GNU} hosts require a colon before alocation name in a @env{TZ} setting, e.g.,@samp{TZ=":America/New_York"}.The @samp{tz} database includes a wide variety of locations rangingfrom @samp{Arctic/Longyearbyen} to @samp{Antarctica/South_Pole}, butif you are at sea and have your own private time zone, or if you areusing a non-@acronym{GNU} host that does not support the @samp{tz}database, you may need to use a @acronym{POSIX} rule instead.  Simple@acronym{POSIX} rules like @samp{UTC0} specify a time zone withoutdaylight saving time; other rules can specify simple daylight savingregimes.  @xref{TZ Variable,, Specifying the Time Zone with @code{TZ},libc, The GNU C Library}.@node Authors of get_date@section Authors of @code{get_date}@cindex authors of @code{get_date}@cindex Bellovin, Steven M.@cindex Salz, Rich@cindex Berets, Jim@cindex MacKenzie, David@cindex Meyering, Jim@cindex Eggert, Paul@code{get_date} was originally implemented by Steven M. Bellovin(@email{smb@@research.att.com}) while at the University of North Carolinaat Chapel Hill.  The code was later tweaked by a couple of people onUsenet, then completely overhauled by Rich $alz (@email{rsalz@@bbn.com})and Jim Berets (@email{jberets@@bbn.com}) in August, 1990.  Variousrevisions for the @sc{gnu} system were made by David MacKenzie, Jim Meyering,Paul Eggert and others.@cindex Pinard, F.@cindex Berry, K.This chapter was originally produced by Fran@,{c}ois Pinard(@email{pinard@@iro.umontreal.ca}) from the @file{getdate.y} source code,and then edited by K.@: Berry (@email{kb@@cs.umb.edu}).

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?