getdate.y语法疑惑 [英] getdate.y grammar doubts

查看:198
本文介绍了getdate.y语法疑惑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<一个href=\"http://www.freebsd.org/cgi/cvsweb.cgi/~checkout~/src/usr.bin/tar/Attic/getdate.y?rev=1.9.12.1;content-type=text%2Fplain;hideattic=0\" rel=\"nofollow\">http://www.freebsd.org/cgi/cvsweb.cgi/~checkout~/src/usr.bin/tar/Attic/getdate.y?rev=1.9.12.1;content-type=text%2Fplain;hideattic=0

我想了解如何 yyTimezone 下code计算方法是:

I am trying to understand how yyTimezone is calculated in code below:

| bare_time  '+' tUNUMBER {
    /* "7:14+0700" */
    yyDSTmode = DSToff;
    yyTimezone = - ($3 % 100 + ($3 / 100) * 60);
}
| bare_time '-' tUNUMBER {
    /* "19:14:12-0530" */
    yyDSTmode = DSToff;
    yyTimezone = + ($3 % 100 + ($3 / 100) * 60);
}

我怎么理解的是,可以说时间戳 2011-01-02T10:15:20-04:00 ;这意味着它的 0400 背后 UTC时间。因此,将其转换成 UTC ,您添加 0400 小时到它,它变成 2011- 01-02T14:15:20 。是我的理解是否正确?

How I understand is, lets say the timestamp is 2011-01-02T10:15:20-04:00; this means its 0400 hours behind UTC. So to convert it into UTC, you add 0400 hours to it and it becomes 2011-01-02T14:15:20. Is my understanding correct?

如何,在codeblock将我上面粘贴的实现?

How is that achieved in the codeblock I pasted above?

推荐答案

输入将EN code失调如 -0400 。在的那0400 部分将返回为 tUNUMBER 标记(presumably拿着一个无符号值)。此标记由语法规则匹配,并且可以用作 $ 3

The input would encode the offset like -0400. The 0400 part of that would be returned as the tUNUMBER token (presumably holding an unsigned value). This token is matched by the grammar rules, and can be used as $3.

要获得实际的距离值分钟偏差 400 ,您必须首先它在两半分开。小时部分可以用 $一百分之三(即 4 ),并与分部分<$ C获得$ C> $ 3%100 (即 0 )。由于有60分钟在一个小时,则乘以60小时,并在分添加到( $ 3%100 +($ 90元/ 100)* 60 ),其将给值 240 。然后,所有剩下的,就是添加符号,并将其存储在 yyTimezone

To get the actual offset in minutes from the value 400, you first have to split it up in two halves. The hours part can be obtained with $3 / 100 (ie. 4), and the minutes part with $3 % 100 (ie. 0). Since there are 60 minutes in an hour, you multiply the hours by 60, and add the minutes to that ($3 % 100 + ($3 / 100) * 60), which would give the value 240. Then all that's left, is to add the sign, and store it in yyTimezone.

在所有这一切, yyTimezone 将包含在时区偏移分钟

After all that, yyTimezone will contain the timezone offset in minutes.

这篇关于getdate.y语法疑惑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆