Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: playing with NOW
Pages: [1] Print
Author Topic: playing with NOW  (Read 459 times)
leke
Jr. Member
**
Offline Offline

Posts: 92


View Profile WWW
playing with NOW
« on: September 06, 2004, 01:19:26 AM »

I checked out Ruby at the weekend and was having a go at some tutorials.
There was an 'numbers excercise' part...

how many seconds old are you?
how many minutes are in a decade?

...which I had a go at in REBOL because I wanted to account for leap years. I thought the NOW function would be really handy for this type of job so I coded 'how many seconds old are you?'.

Code:
REBOL[]
days_old: now - 23-Nov-1975
seconds_old: days_old * 86400
print ["You are" seconds_old "seconds old on this DAY."]

nt: now/time
hour: nt/hour
mins: nt/minute
sec: nt/second
get_seconds: (hour * 3600) + (mins * 60) + sec

exactly: seconds_old + get_seconds

print ["You were" exactly "seconds old when this program was executed!"]
halt
Which worked ok (I think).
But then I tried 'how many minutes are in a decade?' and got stuck.
I was going to work it like...

todays date minus todays date 10 years ago

...which gets my decade with any leap year irregularities thrown in.
I had a lot of problems with this. I could subtract 10 years from now/year, but then couldn't get it back on a whole date value.
I suppose I was then going to get the days between them and convert days-to-minutes.

Any ideas?
Logged

Gabriele
Full Member
***
Offline Offline

Posts: 182


View Profile WWW
playing with NOW
« Reply #1 on: September 06, 2004, 05:53:34 AM »

Code:
>> date-of-birth: 23-Nov-1975
== 23-Nov-1975
>> difference now date-of-birth
== 252370:51:02
>> to integer! difference now date-of-birth
== 908535111

>> date: now
== 6-Sep-2004/12:52:53+2:00
>> ten-years-ago: date
== 6-Sep-2004/12:52:53+2:00
>> ten-years-ago/year: 1994
== 1994
>> ten-years-ago
== 6-Sep-1994/12:52:53+2:00
>> time: difference date ten-years-ago
== 87672:00
>> time/hour * 60
== 5260320
Logged
leke
Jr. Member
**
Offline Offline

Posts: 92


View Profile WWW
playing with NOW
« Reply #2 on: September 08, 2004, 01:03:37 AM »

>> date-of-birth: 23-Nov-1975
== 23-Nov-1975
>> difference now date-of-birth
** Script Error: difference expected set1 argument of type: series bitset
** Near: difference now date-of-birth
>>

How come this goes wrong in my console and not yours?

I'm using:
REBOL/View 1.2.1.3.1 21-Jun-2001

Logged

Gabriele
Full Member
***
Offline Offline

Posts: 182


View Profile WWW
playing with NOW
« Reply #3 on: September 08, 2004, 04:43:51 AM »

1.2.1 is a bit too old. :-)

You should try at least 1.2.8, but I'd suggest one of the latest betas. (i.e. 1.2.47)
Logged
leke
Jr. Member
**
Offline Offline

Posts: 92


View Profile WWW
playing with NOW
« Reply #4 on: September 09, 2004, 01:47:58 AM »

Will do.
Thanks. Cheesy  
Logged

Guest
Guest


Email
playing with NOW
« Reply #5 on: September 09, 2004, 04:05:05 AM »

1.2.1 may be "old"
But it is the current live release:
http://www.rebol.com/view-platforms.html

It would help if those posting code here clearly marked it as "Does not work on current live release -- needs xxx"

That way, those of us who are trying to get _systems_ that are based on stable releases to work. will know to look elsewhere.
Logged
Gabriele
Full Member
***
Offline Offline

Posts: 182


View Profile WWW
playing with NOW
« Reply #6 on: September 09, 2004, 05:16:32 AM »

The only reason 1.2.1 is still the "official" release is the number of platforms. Apparently, noone seems interested in most of the platforms originally supported by View. This means, that the latest betas, even if MORE STABLE that the official 1.2.1 (a huge number of bugs have been fixed, and I think there's only a small part of the REBOL community still using 1.2.1), don't get the "official" status because they have only been tested and made available on a small number of platforms.

To counter this problem. RT has announced that for View 1.3 a number of platforms will be dropped.

Anyway, if you're really interested in stable systems, I'd suggest you checking one of the latest versions if your platforms are supported. You wont regret it. Smiley
« Last Edit: September 09, 2004, 05:17:09 AM by Gabriele » Logged
Pages: [1] Print 
Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: playing with NOW
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 20, 2008, 04:55:13 AM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2285 Posts in 594 Topics by 3705 Members
Latest Member: greachtah

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc