r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Core] Discuss core issues

GrahamC
14-May-2011
[1420x2]
>> to date! now
== 15-May-2011/10:41:51+12:00
>> to date! "15-May-2011"
== 15-May-2011
to date! creates two different types
BrianH
14-May-2011
[1422]
A timestamp more precise than NOW/precise?
GrahamC
14-May-2011
[1423x5]
No, to date! creates either a date only , or a timestamp at present
it's inconsistent
it should create a date at 0:00 and GMT
if those are not provided
A source for errors ....
BrianH
14-May-2011
[1428]
The date! type is a datetime type with an optional time portion. 
We can get rid of the time portion already. What do you want that 
we don't have already?
GrahamC
14-May-2011
[1429]
to date! should create a timezone and hour by default
BrianH
14-May-2011
[1430x3]
But that doesn't work when you don't want a time and date.
>> d: now/date
== 14-May-2011
>> d: now d/time: none d
== 14-May-2011
When you requested a timestamp type, I thought you were requesting 
a timestamp type, not a datetime type.
GrahamC
14-May-2011
[1433]
in databases .. date and timestamp are different
BrianH
14-May-2011
[1434]
In some SQL implementations, date, time and datetime are different. 
And then timestamp is different from all of those.
GrahamC
14-May-2011
[1435]
maybe just need an explicit to-datetime
BrianH
14-May-2011
[1436]
A few SQL implementations call the datetime type "timestamp" for 
some cunfusing reason. It's best to keep the concepts distinct.
GrahamC
14-May-2011
[1437]
at present 'to-date gives you either a date, or a datetime depending 
on the input.  that is inconsistent
BrianH
14-May-2011
[1438]
A TO-DATETIME function would be great. GMT by default, or local time 
like the rest of REBOL?
GrahamC
14-May-2011
[1439]
localtime would be consistent
BrianH
14-May-2011
[1440]
In R3, GMT seems to be the default time zone. Interesting.
GrahamC
14-May-2011
[1441x5]
For many webservices I prefer to work with GMT
For me the issue is that when dealing with dates, I want to get only 
the date, but it it's a date with no time portion, then date/date 
gives you an error.
So, I have to check to see what it is first.
Or, maybe date/date should just not complain!
Better to have a to-datetime function though
BrianH
14-May-2011
[1446]
to-datetime: func ["Converts to date! value." value][

    value: to date! :value unless value/time [value/time: 0:00 value/zone: 
    0:00] value
]
GrahamC
14-May-2011
[1447]
Should this be in /core ?
BrianH
14-May-2011
[1448]
Don't see why not. It also is a simpler solution than splitting the 
date! type into date! and datetime!.
GrahamC
14-May-2011
[1449]
and just a refinement to default to local time
BrianH
14-May-2011
[1450x2]
Given that R3 might get some restrictions, maybe having the /utc 
option like NOW would be better. Like this:

to-datetime: func ["Converts to date! value." value /utc "Universal 
time (no zone)"][

    value: to date! :value unless value/time [value/time: 0:00 value/zone: 
    either utc [0:00] [now/zone]] value
]

But that is starting to get more confusing, since /utc would only 
affect date values without times specified, not convert ones with 
times specified. It might be better to just say that it adds 0:00+0:00 
if not otherwise specified, since that is how dates are defined for 
date arithmetic compatibility between dates with times specified 
and those without.
Given that R3 might get some restrictions
 on the use of /local (there was a blog about it).
GrahamC
14-May-2011
[1452x3]
My other beef is how Rebol formats datetimes
look at this:

15-May-2011/11:15:59+12:00
15-May-2011/11:15:59+12:00
15-May-2011/11:16+12:00
15-May-2011/11:16+12:00
Why should the precision change ?
BrianH
14-May-2011
[1455x2]
The precision didn't change. The date! type has fixed precision, 
not floating point. All missing parts are 0.
There are many competing and conflicting standards for how to format 
dates - REBOL just picked one of the international standards that 
looks more human-readable than most. You can get at the component 
parts if you want to format them differently.
GrahamC
14-May-2011
[1457x3]
Does 11:16:00 look less readable than 11:16 ?
Anyway, I raise this because most web services want times to a fixed 
degree of places.  Not varying by the second
So, my sugggestion is that the number of displayed places should 
always be consistent
BrianH
14-May-2011
[1460]
Does 11:16:00 look less readable than 11:16 ?
 - Yes.
GrahamC
14-May-2011
[1461]
not less readable to a web service though
BrianH
14-May-2011
[1462x2]
The default formatter is pretty much for situations where you don't 
need that kind of inflexibility. Most people don't need the whole 
gamut of different formatting options, since only a small percentage 
of them are used in any given situation. It would be useful to have 
a library of date formatting routines that could support all of the 
many standards. If you need to talk to a service that requires a 
particular format, use a particular formatter.
MOLD only has to be compatible with REBOL syntax, and the more human-readable 
subset at that. To be compatible with less flexible data formats, 
use formatting functions that are specific to those formats.
GrahamC
14-May-2011
[1464x2]
My point is that I think it's an optimization that has bitten more 
than a few people
Maarten's S3 lib has a bug on this account.
BrianH
14-May-2011
[1466]
Date formats have that effect throughout the industry, mostly due 
to the vast number of incompatible formats to choose between. Whatever 
format you choose will be bad for most of the rest of the world.
GrahamC
14-May-2011
[1467]
As long as it works for my world and web services
BrianH
14-May-2011
[1468]
That is not what MOLD is for, that is a job for custom formatting 
functions.
GrahamC
14-May-2011
[1469]
So, what do you suggest?

>> d: 15-may-2011/12:00:00.00
== 15-May-2011/12:00
>> d/time
== 12:00