views:

58

answers:

4

I have a 500K+ lines vb.net app, written by 10+ different devs over the past 5 years. Many times it gets the system time and/or date and relies on it.

Now I have to re-run real cases thru the program for regression testing purposes, and it screws up cases where the date/time matter. My fix is easy, just replace all the areas in the program that get current date/time with a sub that gets the current date/time, UNLESS I'm testing, in which case it will return the date/time of the original run.

I have tried searching the sourcecode for the obvious 'current date/time' functions:

Now
DateAndTime.TimeOfDay
Date.ToDay

However, if I miss one, I LOSE.

Can anybody please list more ways to get the current time, that might be hidden in the source code, that I can search for? Note: It's pretty clear none of the 3rd party libs in this system are returning date, well, one is, but I've caught it. so just from .net or vb. Thanks.

+3  A: 

Find one, right-click, Find All References.

Reflector can help too. Right-click the property getter, Analyze, Used by.

Hans Passant
A: 

Are you worried about database calls that rely on the system time? I often tag records with GetDate().

Bill
+2  A: 

The following also get the current date and time:

DateTime.Now
DateTime.UtcNow
DateTime.Today
DateTimeOffset.Now
DateTimeOffset.UtcNow

Is that all of them? Somehow I doubt it.

Jim Mischel
+2  A: 

Use the technique described by @Hans Passant. For a complete list of VB.NET functions related to system clock, look here.

DateString
Now
TimeOfDay
Timer
TimeString
Today
DateAdd
DateDiff
DatePart
DateSerial
DateValue
Day
IsDate
Month
MonthName
Weekday
Hour
Minute
Second
TimeSerial
TimeValue
Edward Leno
thanks ed, I was just looking for a quick list like this. Your google-fu is strong, mine is weak...
FastAl
Those are the VB.NET specific functions, but you'll probably want to include the .NET Framework functions as well. Look at the `DateTime` and `DateTimeOffset` structures for static methods.
Jim Mischel