Hi Ryan,
the statement "within the same exact thousandth of a second" is not correct. The /precise
refinement still can get only the system time, so the "granularity" of the time you can
get depends on the operating system you use. Some values:
OS Granularity
Windows 95/98 55 ms
Windows NT 10 ms
The value for the granularity can be easily computed with my TIME-TICK function, that
can be found in http://www.sweb.cz/LMecir/timblk.r
Regards
Ladislav
> Hooray!
I have updated my 'time-in-digits function so that it can be
> used with
the /precise refinement for 'now.
I use 'time-in-digits
> exhaustively, because it can be used to create
sequential session IDs
> over time and to create sequential file names
over time.
Because it
> can now handle the /precise refinement, it is very unlikely
you will
> create the same session ID for multiple connections to a CGI
interface
> (which was a possibility previously since more than one
person might
> submit to CGI within the same exact second. Now
there would only be a
> problem if more than one person might submit
to CGI within the same
> exact thousandth of a second.)
-Ryan
REBOL [
Title: "Date and
> time in digits"
Date: 28-Dec-2000
Name: 'time-in-digits
> Version: 1.3.0
File: %time-in-digits.r
Author: "Ryan C.
> Christiansen"
Email: [norsepower--uswest--net]
Owner: "Ryan C.
> Christiansen"
Rights: "Copyright (C) Ryan C. Christiansen 2000"
> Tabs: 4
Language: 'English
Purpose: {
Convert the date
> and time into a string of digits.
}
Comment: {
Use this
> function to create a string of digits denoting
the date and time.
> This is useful, especially for creating
sequential session IDs.
> If used with 'now to create a file
name, the newest file will
> always appear at the end of
a directory.
}
History: [
> 1.0.0 [12-June-2000 "posted to rebol.com" "Ryan"]
1.3.0
> [28-Dec-2000 "updated for /precise refinement" "Ryan"]
]
> Category: [util 2]
]
time-in-digits: func [
"Convert the date and
> time from 'now' into a string of digits."
sun-dial [date!] "The
> current date and time from 'now'"
][
year: to-string sun-dial/year
> month: to-string sun-dial/month
if (length? month) < 2 [insert
> month "0"]
day: to-string sun-dial/day
if (length? day) < 2
> [insert day "0"]
current-time: sun-dial/time
hour: to-string
> current-time/hour
if (length? hour) < 2 [insert hour "0"]
> minutes: to-string current-time/minute
if (length? minutes) < 2
> [insert minutes "0"]
seconds: to-string current-time/second
> seconds-rounded: make integer! current-time/second
either
> current-time/second = seconds-rounded [
whole-seconds: seconds
> partial-seconds: "000"
][
either seconds-rounded = 0 [
> whole-seconds: "00"
time-string: make string! (reform
> current-time)
split-time: parse/all time-string "."
> partial-seconds: second split-time
][
either
> current-time/second = 0 [
whole-seconds: "00"
> partial-seconds: "000"
][
split-seconds: parse/all
> seconds "."
whole-seconds: first split-seconds
> partial-seconds: second split-seconds
]
]
]
while
> [(length? whole-seconds) < 2][insert whole-seconds "0"]
while
> [(length? partial-seconds) < 3][append partial-seconds "0"]
> rejoin [year month day hour minutes whole-seconds partial-seconds]
]
> > This appears to work until the thousandths-of-a-second value reaches
> > either 1,000 or zero (not sure how REBOL is handling this, which is
> where
> the problem lies, I believe.)
>
> Probably goes from 999 and
> roll around to 0, or none.
>
> > ** Script Error: Out of range or past
> end
> > ** Where: time-in-digits
> > ** Near: partial-seconds: second
> split-seconds
> > while [(length? whole-seconds) < 2]
>
> Probably
> 'whole-seconds is 'none ?
>
> I hope that helps!
>
> Andrew Martin
>
> ICQ: 26227169 http://members.nbci.com/AndrewMartin/
> -><-
>
> --
> > To unsubscribe from this list, please send an email to
>
> [rebol-request--rebol--com] with "unsubscribe" in the
> subject, without
> the quotes.
>
--
To unsubscribe from this list, please send an
> email to
[rebol-request--rebol--com] with "unsubscribe" in the
subject,