20

Does anybody know of a Windows tool to report fake dates/times to a process?

Apparently there are Linux programs that can be used to test how the software will react in the future / in a different timezone or to trigger scheduled tasks without actually modifying the system clock. Are there such programs for Windows?

Ishmaeel
  • 14,138
  • 9
  • 71
  • 83

3 Answers3

18

RunAsDate can do this.

rbrayb
  • 46,440
  • 34
  • 114
  • 174
  • 2
    Awesome, thanks. Though it doesn't seem to affect the grand-child processes that the initial process might start, it is better than nothing. – Ishmaeel Jan 13 '09 at 01:14
2

Starting about 2 years ago, I always abstract the call to DateTime.Now (C#) through a Utility class. This way I can always fake the date/time if I want to, or just pass it directly through to DateTime.Now.

Sounds similiar to what BillH suggested.

public class MyUtil
{
  public static DateTime GetDateTime()
  {
     return DateTime.Now.AddHours(5);
     //return DateTime.Now;   
  }
}
BuddyJoe
  • 69,735
  • 114
  • 291
  • 466
  • You mean for this project, right? It wouldn't work system-wide, right? :-) – tmighty Oct 29 '17 at 19:16
  • Correct. Only for a single project. Would be nice if the system gave you a way to abstract this away (at a system level). Can Docker do this? Use a false / incorrect time from the underlying system? I know a Virtual Machine could. – BuddyJoe Nov 08 '17 at 21:21
0

Wrapper your calls to the 'getCurrentDateTime()' system calls so you can introduce offsets or multipliers into the times your code reads during testing?

RichH
  • 6,108
  • 1
  • 37
  • 61