1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-09 05:20:36 -04:00
elinks/src/protocol
Kalle Olavi Niemitalo 45d1750d03 Bug 914: Don't let UTF-8 I/O affect internal representations.
Use it for the actual I/O only.  Previously, defining CONFIG_UTF8 and
enabling UTF-8 used to force many strings to the UTF-8 charset
regardless of the terminal charset option.  Now, those strings always
follow the terminal charset.  This fixes bug 914 which was caused
because _() returned strings in the terminal charset and functions
then assumed they were in UTF-8.  This reduction in the effects of
UTF-8 I/O may also simplify future testing.
2007-05-20 15:31:02 +03:00
..
auth Mark all module names for translation and include needed header files. 2007-03-21 11:01:06 +01:00
bittorrent Bug 914: Don't let UTF-8 I/O affect internal representations. 2007-05-20 15:31:02 +03:00
file file: Directory listings are in the system charset. 2007-03-20 20:50:41 +02:00
finger NET: Move cache entry normalization to abort_connection 2006-02-08 21:40:08 +01:00
fsp fsp: Try to recover from ABI mismatches caused by _FILE_OFFSET_BITS. 2007-03-06 15:57:18 +02:00
ftp Bug 941: Survive an unexpected number of 227 or 229 FTP responses. 2007-04-12 01:02:00 +03:00
gopher Trim trailing whitespaces. 2006-07-27 09:51:10 +02:00
http show_http_error_document: Generate a charset parameter. 2007-03-20 20:53:03 +02:00
nntp NNTP: Use state instead of conn->state, since it hasn't been updated yet 2006-02-08 21:04:19 +01:00
rewrite Document the syntax of protocol.rewrite.default_template. 2007-03-10 12:15:06 +02:00
smb do_smb: URI-encode the username and password. 2007-03-25 12:13:46 +03:00
about.c about_protocol_handler: Don't define len if CONFIG_SMALL. 2006-12-10 17:16:38 +02:00
about.h Remove empty lines in start of header files 2005-11-15 11:33:27 +01:00
common.c Use add_string_to_string where applicable. 2007-03-18 20:29:08 +02:00
common.h DIRLIST: Add helper to at start of (HTML) directory listing 2006-01-30 01:22:31 +01:00
data.c Cast the NULL argument of straconcat to unsigned char *. 2007-03-11 12:59:11 +02:00
data.h Remove empty lines in start of header files 2005-11-15 11:33:27 +01:00
date.c Bug 924, my_timegm: Added a comment about 2100 not being a leap year. 2007-01-13 15:38:02 +02:00
date.h Remove empty lines in start of header files 2005-11-15 11:33:27 +01:00
header.c parse_header_param: better describe behaviour when @ret is NULL 2006-06-23 06:07:22 +00:00
header.h parse_header_param stores the string via a pointer parameter. 2006-06-05 20:22:53 +00:00
Makefile DIRLIST: Add helper to at start of (HTML) directory listing 2006-01-30 01:22:31 +01:00
protocol.c Type-check button arguments of msg_box. 2007-03-10 23:50:56 +02:00
protocol.h - FSP protocol 2006-01-16 11:40:13 +01:00
proxy.c Cast the NULL argument of string_concat to unsigned char *. 2007-03-11 13:01:50 +02:00
proxy.h enum connection_state instead of int to satisfy tcc 2006-04-05 16:27:16 +02:00
README.timegm Move README.timegm to the same directory as date.c. 2007-01-13 10:01:51 +02:00
uri.c More const in URI functions. 2007-03-18 09:57:29 +02:00
uri.h More const in URI functions. 2007-03-18 09:57:29 +02:00
user.c If there is nothing to write do not even open the file for write (test 2007-03-05 21:37:24 +01: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