This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
The applications that I work with always store the date as utc and not local time. The "Convensions" page states this: Timestamps for the CreatedOn, UpdatedOn and DeletedOn columns are always the current local time of the computer where LightSpeed is running. Is there a way to use UTCDate instead of Local DateTime? Thank you, Joe Feser |
|
|
We don't have that option at the moment but we agree it should be there and are just discussing some implementation options. We'll probably try to slot it in in the next few days (though no promises!). |
|
|
Ok, I will check back on Friday. :) Thanks. Joe |
|
|
Hi Joe, This is now done and will be included in nightly builds dated 18 Feb 2009 and above. Set LightSpeedContext.AutoTimestampMode = AutoTimestampMode.Utc to use UTC timestamps for the three automatic fields. Please note that timestamps are still generated on the machine running LightSpeed -- we do *not* call the database getutcdate or equivalent. |
|
|
Ivan, I assume you are using DateTime.UtcNow so that would be fine anyway. If the sql server is out of sync time wise then the user has bigger issues to deal with. I would say it is acceptable to be +/- 2 seconds or so (commit time). May I ask what took so long. :) You guys react even quicker than we do on NCover. :) I will check it out in the next day or so. Thanks Joe |
|
|
Hi Ivan, Great to see this has gone into the build :-) I haven't checked the latest nightly yet so appologies in advance if its a stupid question. I'm just wondering if with this addition you provided the ability to provide a custom time provider that LS would use to get the time from (implement some kind of time interface)? For me this would be a great feature for unit testing/being able to inject the time provider for these auto generated fields...then I can do things like fix the time etc... If you need any more info flick me a message back. Cheers, James |
|
|
Hi James, Internally we implement this using a time provider, but we do not currently provide a way to specify a custom time provider. However, all we need to do to enable your scenario is (a) make the time provider interface public and (b) provide a way for you to specify your own time provider class. The latter is slightly tricky because we deliberately chose to select the time provider via an enum rather than a class name/instance: the reason for this was to keep the config interface nice and simple. We therefore need to have a quick think about how to allow users to specify custom providers. E.g. a Custom enum value, and an additional context property that you would only need to set up if the timestamp policy was set to Custom. Oh, if only .NET had something like enums but, I dunno, more dynamic... *grin* I'll poll the troops and once we're agreed on the API, this should be an easy change. |
|
|
lol - thanks Ivan :-) Sounds good!
|
|
|
Righty ho, this is now in and will be available in nightly builds dated 28 Feb 2009 and above. The deal is that you need to do two things: - First, set LightSpeedContext.AutoTimestampMode to Custom - Second, set LightSpeedContext.CustomAutoTimestampStrategy to an object that implements IAutoTimestampStrategy. I have not rebuilt the docs yet, so some quick API documentation. IAutoTimestampStrategy has two members: AutoTimestampMode, which should just return Custom, and GetTime(), which you can use to return your fixed time or a predictable sequence of times or whatever it is you require for your tests. Please note that you cannot currently set CustomAutoTimestampStrategy through configuration. As your use case is testing, I'm assuming this will not be an issue for you. |
|
|
Thanks Ivan :-) Awesome stuff |
|
|
Hi, It looks like the docs haven't been updated with this information yet but it is something I want to use. I've set the AutoTimeStampMode configuration parameter programmatically which is fine for the time being but I can't get it to work in the config file. I tried these XML attributes with no success (unrecognised attribute): autoTimeStampMode="AutoTimestampMode.Utc" Is there a supported configuration file option yet? Thanks, Chris |
|
|
autoTimestamps="Utc" is the incantation you need. |
|