1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-20 01:46:15 -04:00
elinks/src/protocol
Miciah Dashiel Butler Masters f8bdc3ca9e read_http_post_inline: fix assertion-failed message
read_http_post_inline decodes two hexadecimal digits into one byte at
a time, and it asserts that each hexadecimal digit is valid; however,
both assertions print the first digit when they fail.  Fix the assertion
on the second digit to print the second digit.
2011-11-14 04:34:50 +00:00
..
auth Memorize the auth form only when the "document.browse.forms.show_formhist" is on. 2011-10-06 10:54:11 +02:00
bittorrent find_clonable_bittorrent_peer_request(): Remove likely wrong inner clone declaration 2011-09-24 02:21:59 +02:00
file Allow empty /dev/stdin 2010-07-31 21:48:48 +02:00
finger Bug 1013: Don't assume errno is between 0 and 100000 2008-08-03 17:56:41 +03:00
fsp Merge branch 'elinks-0.12' into elinks-0.13 2008-08-03 22:18:53 +03:00
ftp ftp: Get filesize from SIZE command instead of guess it from RETR command. 2011-03-22 17:51:13 +01:00
gopher Merge branch 'elinks-0.12' into elinks-0.13 2008-11-01 22:39:17 +02:00
http read_http_post_inline: fix assertion-failed message 2011-11-14 04:34:50 +00:00
nntp Remove variables that were set but not used 2011-09-24 02:25:51 +02:00
rewrite Merge branch 'elinks-0.12' into elinks-0.13 2009-03-12 08:46:02 +02:00
smb SMB directory listing looks like normal directory listing. 2010-09-06 18:38:36 +02:00
test Compilation fix. make test failed. 2010-08-08 09:38:39 +02:00
about.c Bug 1013: Don't assume errno is between 0 and 100000 2008-08-03 17:56:41 +03:00
about.h Remove empty lines in start of header files 2005-11-15 11:33:27 +01:00
common.c Bug 1013: Don't assume errno is between 0 and 100000 2008-08-03 17:56:41 +03:00
common.h Bug 1013: Don't assume errno is between 0 and 100000 2008-08-03 17:56:41 +03:00
data.c Bug 1013: Don't assume errno is between 0 and 100000 2008-08-03 17:56:41 +03:00
data.h Remove empty lines in start of header files 2005-11-15 11:33:27 +01:00
date.c parse_time: set tm_sec to zero before conditional second parsing 2008-02-28 23:38:42 +02:00
date.h Remove empty lines in start of header files 2005-11-15 11:33:27 +01:00
header.c Patch 2: Modifications to the remaining parts of ELinks 2008-11-01 22:20:25 +02:00
header.h parse_header_param stores the string via a pointer parameter. 2006-06-05 20:22:53 +00:00
Makefile Bug 744: Add tests. There are four failures. 2007-07-19 13:46:47 +03:00
protocol.c Unification of protocol handler names. 2010-07-27 10:07:52 +02:00
protocol.h Handle mailcap's copiousoutput without an external pager. 2010-07-24 17:07:18 +02:00
proxy.c Merge branch 'elinks-0.12' into elinks-0.13 2008-11-01 22:39:17 +02:00
proxy.h Bug 1013: Don't assume errno is between 0 and 100000 2008-08-03 17:56:41 +03:00
README.timegm Move README.timegm to the same directory as date.c. 2007-01-13 10:01:51 +02:00
uri.c Revert "strcpy -> strlcpy." 2010-09-19 15:26:05 +02:00
uri.h 1008: percent-encode file names in uri.post 2008-07-11 14:44:35 +03:00
user.c Rewrap lines in option documentation. 2009-03-08 15:18:10 +02:00
user.h Remove empty lines in start of header files 2005-11-15 11:33:27 +01:00

This file contains description of our my_timegm() function in date.c. It was
posted as a mail to links-list by Stephane Chazelas, and I thought it may be
interesting for someone, so I decided to include it in the ELinks distribution.




Un explanation for it as one (me to start with) may wonder why
this works.

We first change of calendar. To make things easy, let's say
that 0/0/0 0:0:0 in our new calendar is the Marsh 1st 1968, so
just after a february 29th as 1968 was a leap year.

if y/m/d h:min:s is time in our calendar
and
   Y/M/D h:min:s in the new calendar

M = m - 1 - 2 (+ 12 if m < 3)
Y = y - 68 (-1 if m < 3)
D = d - 1

at Y/0/0 0:0:0, there has been Y / 4 leap years in the past, so
(int) 365 * Y + Y / 4 days have past.

at Y/M/0 0:0:0, lets find how many days have past since Y/0/0:

                   |Mar                                        Feb
                  M| 0   1   2   3   4   5   6   7   8   9  10  11
-------------------+-----------------------------------------------
 days in that month|31  30  31  30  31  31  30  31  30  31  31  28 or 29
-------------------+-----------------------------------------------
  x = days at Y/M/0| 0  31  61  92 122 153 184 214 245 275 306 337
-------------------+-----------------------------------------------
first approximation|
         y = 30 * M| 0  30  60  90 120 150 180 210 240 270 300 330
-------------------+-----------------------------------------------
              x - y| 0   1   1   2   2   3   4   4   5   5   6   7
-------------------+-----------------------------------------------
(M + 4) * 3 / 5 - 2| 0   1   1   2   2   3   4   4   5   5   6   7
-------------------+-----------------------------------------------

x - y = (M + 4) * 3 / 5 - 2

x = 30 * M + (M + 4) * 3 / 5 - 2

x = (153 * M + 2) / 5

So at Y/M/D 0:0:0,

Y * 1461 / 4 + (153 * M + 2) / 5 + D days have past since
the 1st of March of 1968

1st of March of 1968 was 671 days before 1970 Jan 1st (year 0
for unix time())

So
t = s + 60 * (min + 60 * (h + 24 * (Y * 1461 / 4 + (153 * M + 2) / 5 + D - 671)))
t = s + 60 * (min + 60 * (h + 24 * (Y * 1461 / 4 + (153 * M + 2) / 5 + d - 672)))

This shouldn't work past 2100/02/28 23:59:59 as 2100 is not a leap year.

--
St<53>phane