I am trying to efficiently get the date part of a Time object.
To remove the time part of the Time object I subtract the modulo of a
day-in-seconds. But if I do this I get a Time object of the date *plus
1 hour*!!! Perhaps I'm just tired, but I don;t understand why.
Greg Lorriman scribbled on Wednesday 15 Mar 2006 12:55:
I am trying to efficiently get the date part of a Time object.
To remove the time part of the Time object I subtract the modulo of a
day-in-seconds. But if I do this I get a Time object of the date *plus
1 hour*!!! Perhaps I'm just tired, but I don;t understand why.
I am trying to efficiently get the date part of a Time object.
To remove the time part of the Time object I subtract the modulo of a
day-in-seconds. But if I do this I get a Time object of the date *plus
1 hour*!!! Perhaps I'm just tired, but I don;t understand why.
Indeed. I just discovered http://www.recentrambles.com/pragmatic/view/33 from another thread.
Interestingly enough, by replacing DateTime with Date in the example,
the benchmark comes out about 3 times faster. I guess having to work
with hours, minutes, and seconds is expensive.
- Dimitri
···
On 3/15/06, Greg Lorriman <temp@lorriman.com> wrote:
Unfortunately the Date class is horrifically slow. I'm already being
hammered by other slow aspects of ruby, which I can't avoid. So Time it
is!
Unfathomable! What does it mean?!?! I am entirely perplexed by this
reality.
Greg, sorry for the noise. Time.at(0) is "epoch" (1970-01-01 00:00:00 GMT). My timezone is GMT + 1, so epoch happened to be at 1 o'clock. I suppose that's the reason why your algorithm didn't work.
It makes me think that an effort is needed to convert many of the
libraries that do basic heavy-lifting, like DateTime and CSV and
others, to C libraries.
I like the purity of the idea of a "pure Ruby" library, but I am
suffering the consequences and even considering jumping to Python; the
pain is getting to be too much.
Unfathomable! What does it mean?!?! I am entirely perplexed by this
reality.
Greg, sorry for the noise. Time.at(0) is "epoch" (1970-01-01 00:00:00
GMT). My timezone is GMT + 1, so epoch happened to be at 1 o'clock. I
suppose that's the reason why your algorithm didn't work.
Well that is the answer, then. Thankyou very much for that. Perhaps the
docs need expanding a little. I think even a computer scientist might
trip up on "epoch". I was thinking, in fact, that Time isn't a
practical Time/Date implementation and was possibly concieved in an
academic mind, which your observation would seem to confirm; I don't
think I've ever used such an awkward time/date implementation. However
I haven't used Date yet!!!
check out the speed gains one can get with FasterCSV and reconsider - and it's
still pure ruby.
regards.
-a
···
On Thu, 16 Mar 2006, Greg Lorriman wrote:
It makes me think that an effort is needed to convert many of the
libraries that do basic heavy-lifting, like DateTime and CSV and
others, to C libraries.
I like the purity of the idea of a "pure Ruby" library, but I am
suffering the consequences and even considering jumping to Python; the
pain is getting to be too much.
--
share your knowledge. it's a way to achieve immortality.
- h.h. the 14th dali lama
I like the purity of the idea of a "pure Ruby" library, but I am
suffering the consequences and even considering jumping to Python; the
pain is getting to be too much.
check out the speed gains one can get with FasterCSV and reconsider - and it's
still pure ruby
Sounds promising. I particularly like the sound of "Faster", in
"FasterCSV".