date_cache_bug.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. WScript.Echo("Checking for new Date() with DST issues: ");
  6. WScript.Echo("Backward loop starts");
  7. for (var working = new Date(2014, 2, 1) ; working.getFullYear() > 1940;)
  8. {
  9. var dayOfMonth = working.getDate();
  10. var nextYear = working.getFullYear();
  11. var nextMonth = working.getMonth();
  12. dayOfMonth -= 1;
  13. working = new Date(nextYear, nextMonth, dayOfMonth);
  14. if (working.getHours() > 0)
  15. {
  16. WScript.Echo("" + working + " from:" + nextYear + "," + nextMonth + "," + dayOfMonth + "");
  17. dayOfMonth--;
  18. working = new Date(nextYear, nextMonth, dayOfMonth); //skip over this date
  19. }
  20. }
  21. WScript.Echo("Forwards loop starts");
  22. for (var working = new Date(1940, 0, 0) ; working.getFullYear() < 2014;)
  23. {
  24. var dayOfMonth = working.getDate();
  25. var nextYear = working.getFullYear();
  26. var nextMonth = working.getMonth();
  27. dayOfMonth += 1;
  28. working = new Date(nextYear, nextMonth, dayOfMonth);
  29. if (working.getHours() > 0)
  30. {
  31. WScript.Echo("" + working + " from:" + nextYear + "," + nextMonth + "," + dayOfMonth + "");
  32. dayOfMonth++;
  33. working = new Date(nextYear, nextMonth, dayOfMonth); //skip over this date
  34. }
  35. }
  36. WScript.Echo("done.");