VA 8 Beta 1: Timestamps again...

VA Smalltalk is a "100% VisualAge compatible" IDE that includes the original VisualAge technology and the popular VA Assist and WidgetKit add-ons.

Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig

VA 8 Beta 1: Timestamps again...

Postby jtuchel » Thu Jan 08, 2009 12:12 am

Hi there,

over the last few releases, AbtTimestamp has undergone some changes, most of the time breaking some code in customers' applications.
VA 8 seems to not make a difference here. We have some code to serialize timestamps by saving the number of (the smallest possible units - was milli, is now microseconds since I think VAST 6). With Version 7.0 we used timestampValue and timestampValue: , but at least in VA 8 Beta 1 these are gone. The method microSeconds only returns the number of microSeconds that exceed the milliSeconds, and it seems there is no getter / setter /creation method for a total number ogf microSeconds. To make things even more complicated, milliSeconds: is marked as depracated.

Therefore we are faced with two annoyances:
1) our code is broken (again) due to changes to the class
2) I can't find an obvious way to fix it

What would you suggest?
* Convert an AbtTimestamp to a DateAndTime instance for (de-)serializing (there seems to be no method to convert DateAndTime into an AbtTimestamp, btw. Only AbtTimestamp implenments abtAsTimestamp)
* Access the date, time and microseconds values separately and doing the math

Not using AbtTimestamp is not an option, because there's a lot of legacy code using the class, and loads of data is stored using timestamps. This data is mostly stored in DB2 on z/OS, and there Timestamps have microSeconds. DateAndTime doesn't have microseconds...

So in addition to answering my question above, I'd ask Instantiations to consider implementing timestampValue or an equivalent method in VA 8. We need to get/set the number of microseconds since base day. In Beta 1 find no valid solution for this problem...

cu and thx

Joachim
jtuchel
[|]
 
Posts: 245
Joined: Fri Oct 05, 2007 1:05 am
Location: Ludwigsburg, Germany

Re: VA 8 Beta 1: Timestamps again...

Postby wembley » Thu Jan 08, 2009 9:01 am

Joachim -

AbtTimestamp is certainly our problem child. :oops:

Well, timestampValue and timestampValue: were private methods categorized as AbtBase-Internal. This means 'use at your own risk'. However, in the interest of keeping you sane, I will add back timestampValue and timestampValue: as private deprecated methods.
Code: Select all
!AbtTimestamp privateMethods !

timestampValue
   "Answer the value of the receiver in microseconds.  This is the number of microseconds that
    have elapsed since 00:00:00 on the base date (January 1st, 1901)."

   ^(self date asMilliseconds + self time asMilliseconds) * 1000 + self microSeconds!

timestampValue: anInteger
   "Set the receiver to @anInteger number of microseconds.  This is the number of microseconds that
    have elapsed since 00:00:00 on the base date (January 1st, 1901)."

   | millisecondValue timeMilliseconds |

   millisecondValue := anInteger // 1000.
   timeMilliseconds := millisecondValue \\ Time millisecondsPerDay.

   self
      date: (Date fromDays: millisecondValue - timeMilliseconds // Time millisecondsPerDay);
      time: (Time fromMilliseconds: timeMilliseconds);
      microSeconds: (anInteger rem: 1000)
! !

AbtTimestamp categoriesFor: #'timestampValue' are: #('AbtBase-Deprecated')!
AbtTimestamp categoriesFor: #'timestampValue:' are: #('AbtBase-Deprecated')!

There never have been DateAndTime>>#abtCanBeTimestamp and DateAndTime>>#asAbtTimestamp methods as far as I know.

While I was making these additions, I noticed that the latest version of AbtTimestamp is not in V8 Beta1. Because of this, some users may have difficulty serializing AbtTimestamps into Timestamp fields in DB2 and Oracle. This will be fixed in Beta2 (together with the above additions).
John O'Keefe [|], Principal Smalltalk Architect, Instantiations Inc.
wembley
Moderator
 
Posts: 405
Joined: Mon Oct 16, 2006 3:01 am
Location: Durham, NC

Re: VA 8 Beta 1: Timestamps again...

Postby jtuchel » Fri Jan 09, 2009 9:46 pm

John,

thanks for answering.

>Well, timestampValue and timestampValue: were private methods categorized as AbtBase-Internal.

Oops, I successfully managed to not realize this back when I used it for serializing Timestamps. My fault.
Put that aside, I think it should be easy to ask a Timestamp for its number of base units, no matter what the name of the method is.
Is there any reason why you marked the method as private and deprecated?
It seems like the purpose of timesampValue was exactly what I wanted... maybe asMicroseconds would be a nice name for such a method..

Joachim
jtuchel
[|]
 
Posts: 245
Joined: Fri Oct 05, 2007 1:05 am
Location: Ludwigsburg, Germany

Re: VA 8 Beta 1: Timestamps again...

Postby wembley » Mon Jan 19, 2009 1:31 pm

Joachim -

OK, here is the final resolution:

1) Reintroduce timestampValue and timestampValue: private methods categorized as Abt-Internal and Abt-Deprecated (which means that they should not be used and will likely be removed in the future at my convenience)
2) Introduce new AbtTimestamp class>>#fromMicroseconds: and AbtTimestamp>>#asMicroseconds public methods categorized as AbtBase-API that will survive any future modifications of this class.

Case 38757.
John O'Keefe [|], Principal Smalltalk Architect, Instantiations Inc.
wembley
Moderator
 
Posts: 405
Joined: Mon Oct 16, 2006 3:01 am
Location: Durham, NC

Re: VA 8 Beta 1: Timestamps again...

Postby jtuchel » Tue Jan 20, 2009 12:40 am

John,

thanks for looking into this. I like your suggestion and could give up on timestampValue immedialtely. I find asMicroseconds and fromMicroseconds: great replacements. This naming can even survive future changes to the class.

Joachim
jtuchel
[|]
 
Posts: 245
Joined: Fri Oct 05, 2007 1:05 am
Location: Ludwigsburg, Germany


Return to VA Smalltalk 7.0, 7.5 & 8.0

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest