[#11822] RCR: Input XML support in the base Ruby — Dave Thomas <Dave@...>

15 messages 2001/03/01

[#11960] Not Ruby, for me, for the moment at least — "Michael Kreuzer" <mkreuzer@... (nospam)>

I wrote on this newsgroup last weekend about how I was considering using

11 messages 2001/03/04

[#12023] French RUG ? — "Jerome" <jeromg@...>

Hi fellow rubyers,

16 messages 2001/03/05

[#12103] disassembling and reassembling a hash — raja@... (Raja S.)

Given a hash, h1, will the following always hold?

20 messages 2001/03/06

[#12204] FEATURE REQUEST: 'my' local variables — Leo Razoumov <see_signature@127.0.0.1>

Ruby is, indeed, a very well designed language.

64 messages 2001/03/07
[#12250] Re: FEATURE REQUEST: 'my' local variables — Leo Razoumov <see_signature@127.0.0.1> 2001/03/07

>>>>> "GK" == GOTO Kentaro <gotoken@math.sci.hokudai.ac.jp> writes:

[#12284] Re: FEATURE REQUEST: 'my' local variables — gotoken@... (GOTO Kentaro) 2001/03/08

In message "[ruby-talk:12250] Re: FEATURE REQUEST: 'my' local variables"

[#12289] Re: FEATURE REQUEST: 'my' local variables — matz@... (Yukihiro Matsumoto) 2001/03/08

Hi,

[#12452] Re: FEATURE REQUEST: 'my' local variables — gotoken@... (GOTO Kentaro) 2001/03/12

In message "[ruby-talk:12289] Re: FEATURE REQUEST: 'my' local variables"

[#12553] Re: FEATURE REQUEST: 'my' local variables — Dave Thomas <Dave@...> 2001/03/13

matz@zetabits.com (Yukihiro Matsumoto) writes:

[#12329] Math package — Mathieu Bouchard <matju@...>

18 messages 2001/03/09

[#12330] Haskell goodies, RCR and challenge — Robert Feldt <feldt@...>

Hi,

19 messages 2001/03/09
[#12374] Re: Haskell goodies, RCR and challenge — matz@... (Yukihiro Matsumoto) 2001/03/10

Hi,

[#12349] Can Ruby-GTK display Gif Png or Jpeg files? — Phlip <phlip_cpp@...>

Ruby-san:

20 messages 2001/03/09

[#12444] class variables — Max Ischenko <max@...>

14 messages 2001/03/12

[#12606] Order, chaos, and change requests :) — Dave Thomas <Dave@...>

17 messages 2001/03/14

[#12635] email address regexp — "David Fung" <dfung@...>

i would like to locate probable email addresses in a bunch of text files,

12 messages 2001/03/14

[#12646] police warns you -- Perl is dangerous!! — Leo Razoumov <see_signature@127.0.0.1>

I just read this story on Slashdot

14 messages 2001/03/14
[#12651] Re: police warns you -- Perl is dangerous!! — pete@... (Pete Kernan) 2001/03/14

On 14 Mar 2001 11:46:35 -0800, Leo Razoumov <see_signature@127.0.0.1> wrote:

[#12691] Re: police warns you -- Perl is dangerous!! — "W. Kent Starr" <elderburn@...> 2001/03/15

On Wednesday 14 March 2001 15:40, Pete Kernan wrote:

[#12709] [OFFTOPIC] Re: police warns you -- Perl is dangerous!! — Stephen White <spwhite@...> 2001/03/16

On Fri, 16 Mar 2001, W. Kent Starr wrote:

[#12655] Re: FEATURE REQUEST: 'my' local variables — "Benjamin J. Tilly" <ben_tilly@...>

>===== Original Message From Leo Razoumov <see_signature@127.0.0.1> =====

18 messages 2001/03/14

[#12706] Library packaging — "Nathaniel Talbott" <ntalbott@...>

I have a project that I'm working on that needs to live two different lives,

30 messages 2001/03/16

[#12840] Looking for a decent compression scheme — Dave Thomas <Dave@...>

14 messages 2001/03/19

[#12895] differences between range and array — "Doug Edmunds" <dae_alt3@...>

This code comes from the online code examples for

16 messages 2001/03/20
[#12896] Re: differences between range and array — "Hee-Sob Park" <phasis@...> 2001/03/20

[#12899] Re: differences between range and array — Jim Freeze <jim@...> 2001/03/20

On Tue, 20 Mar 2001, Hee-Sob Park wrote:

[#12960] TextBox ListBox — Ron Jeffries <ronjeffries@...>

Attached is a little Spike that Chet and I are doing. It is a

13 messages 2001/03/20

[#12991] [ANN] Lapidary 0.2.0 — "Nathaniel Talbott" <ntalbott@...>

Well, here's my first major contribution to the Ruby world: Lapidary. It's a

16 messages 2001/03/20

[#13028] mkmf question — Luigi Ballabio <luigi.ballabio@...>

15 messages 2001/03/21

[#13185] Reading a file backwards — "Daniel Berger" <djberg96@...>

Hi all,

21 messages 2001/03/25
[#13197] Re: Reading a file backwards — "Daniel Berger" <djberg96@...> 2001/03/25

> Hi Dan,

[#13203] Re: Reading a file backwards — Mathieu Bouchard <matju@...> 2001/03/25

On Sun, 25 Mar 2001, Daniel Berger wrote:

[#13210] Re: Reading a file backwards — "Daniel Berger" <djberg96@...> 2001/03/25

"Mathieu Bouchard" <matju@sympatico.ca> wrote in message

[#13374] Passing an array to `exec'? — Lloyd Zusman <ljz@...>

I'd like to do the following:

15 messages 2001/03/31

[#13397] Multidimensional arrays and hashes? — Lloyd Zusman <ljz@...>

Is it possible in ruby to make use of constructs that correspond to

14 messages 2001/03/31

[ruby-talk:13348] Re: Time Travel with Ruby

From: "Samuel Kilchenmann" <skilchen@...>
Date: 2001-03-29 23:40:05 UTC
List: ruby-talk #13348
"Yukihiro Matsumoto" <matz@zetabits.com> schrieb im Newsbeitrag
news:985813012.022868.21589.nullmailer@ev.netlab.zetabits.com...
> In message "[ruby-talk:13279] Re: Time Travel with Ruby"
>     on 01/03/29, Ernest Ellingson <erne@powernav.com> writes:
>
> |Well you can blame it on Windows but has anyone tried this on other
systems.
> |t=Time.local(2001, 4,1,2,0)
> |puts t
>
> This prints "Sun Apr 01 03:00:00 EDT 2001" on my Linux box.
> Since my timezone does not have DST, I tried on your timezone.
> FYI, Ruby had a bug in DST boundary on versions prior to 2000-07-20.
>

First and most important:
Thanks a lot for this very interesting programming language!

Unfortunately Time.local also behaves strangely on my W95 notebook:

Time.local on an unpatched ruby-1.6.2 is systematically 1 hour off
during DST on my system. In Switzerland as in other european countries
we switched to DST on 2000-03-25 02:00:00, so we lost the hour from
02:00 to 02:59.

puts Time.local(2001, 3, 25, 1, 59, 59)
==> Sun Mar 25 00:59:59 GMT+1:00 2001    # wrong
puts Time.local(2001, 3, 25, 2, 0, 0)
==> Sun Mar 25 03:00:00 GMT+1:00 2001    # dubious
puts Time.local(2001, 3, 25, 3, 0, 0)
==> Sun Mar 25 04:00:00 GMT+1:00 2001    # wrong

We will switch back from DST on 2000-10-28 02:00:00

puts Time.local(2001, 10, 28, 0, 0, 0)
==> Sun Oct 28 01:00:00 GMT+1:00 2001    # still wrong
puts Time.local(2001, 10, 28, 1, 0, 0)
==> Sun Oct 28 01:00:00 GMT+1:00 2001    # strangely enough this is
                                         # correct the hour from
                                         # 01:00 to 02:00 on
                                         # 2001-10-28 is the only hour
                                         # where Ruby gets the correct
                                         # time during DST
puts Time.local(2001, 10, 28, 2, 0, 0)
==> Sun Oct 28 02:00:00 GMT+1:00 2001    # correct

the last sunday in march (when we will switch to DST again) in 2002 is
2002-03-31

puts Time.local(2002, 3, 31, 0, 59, 59)
==> Sun Mar 31 00:59:59 GMT+1:00 2002    # correct
puts Time.local(2002, 3, 31, 1, 0, 0)
==> Sun Mar 31 00:00:00 GMT+1:00 2002    # wrong
etc.

(as you see Cygwin on W95 doesn't display correct TimeZone
descriptions during DST, but i didn't check what would be needed to
change Cygwin to use the TZ descriptions from Windows. The routine
make_time_t from time.c displays the same strange behavior if it is
compiled with VC6 which requires the replacement of gettimeofday by a
simple call to time(NULL))

I applied the following patch to time.c to fix the strange behavior of
ruby-1.6.2's Time.local on my W95 box.
I have no idea if this patch is also working on other systems.

--%<------------------------------------------------------

*** time.c Fri Dec 22 03:22:04 2000
--- time.c.new Thu Mar 29 22:35:54 2001
*************** make_time_t(tptr, utc_or_local)
*** 357,365 ****
   }
   tm = localtime(&guess);
   if (!tm) goto error;
!  if (lt.tm_isdst != tm->tm_isdst) {
!      guess -= 3600;
   }
  #endif
   if (guess < 0) {
       goto out_of_range;
--- 357,368 ----
   }
   tm = localtime(&guess);
   if (!tm) goto error;
!  if (tm->tm_isdst) {
!      if (lt.tm_isdst == tm->tm_isdst || !lt.tm_isdst) {
!          guess -= 3600;
!      }
   }
+
  #endif
   if (guess < 0) {
       goto out_of_range;

--%<------------------------------------------------------

I used this script to check my patch. Store it as e.g. timelocal.rb
and call it as
ruby timelocal.rb year month day hours minutes seconds
e.g.
ruby timelocal.rb 2001 3 25 3 0 0

--%<------------------------------------------------------

def timegm(*args)
  args.push(1)
  mk_time(*args)
end

def timelocal(*args)
  mk_time(*args)
end

def mk_time(year, month, day, hours=0, minutes=0, seconds=0,
gm_flag=0)
  below_secs = 0
  above_secs = (2 ** 31 - 1).to_i
  secs = (below_secs + above_secs) / 2

  inputs = [year, month, day, hours, minutes, seconds]
  tests = []
  compare = 0
#  counter = 0

  while (below_secs <= above_secs)
#    counter += 1
    secs = (below_secs + above_secs) / 2
    if (gm_flag == 0)
      tests = ((Time.at(secs).to_a)[0..5]).reverse
    else
      tests = ((Time.at(secs).gmtime.to_a)[0..5]).reverse
    end

    compare = inputs <=> tests

    if (compare == 0)
#      puts "found after #{counter} iterations"
      return secs
    elsif (compare < 0)
      above_secs = secs - 1
    elsif (compare > 0)
      below_secs = secs + 1
    else
      raise "something terrible"
    end
  end

  raise "date non-existant #{inputs.join(', ')}"
end

if __FILE__ == $0
  args = ARGV.map {|i| i.to_i}

  t = timelocal(*args)
  print "timelocal:  "
  puts Time.at(t)

  t = timegm(*args)
  print "timegm:     "
  puts Time.at(t).utc

  t = Time.local(*args).to_i
  print "Time.local: "
  puts Time.at(t)

  t = Time.gm(*args).to_i
  print "Time.gm:    "
  puts Time.at(t).utc
end
--%<------------------------------------------------------



In This Thread

Prev Next