option_todayhighlight.html 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <link rel="stylesheet" href="assets/common.css">
  5. <script src="assets/common.js"></script>
  6. <script>
  7. function patch_date(f) {
  8. const NativeDate = window.Date;
  9. const date = function date(y,m,d,h,i,s,j){
  10. switch(arguments.length){
  11. case 0: return new NativeDate(date.now());
  12. case 1: return new NativeDate(y);
  13. case 2: return new NativeDate(y,m);
  14. case 3: return new NativeDate(y,m,d);
  15. case 4: return new NativeDate(y,m,d,h);
  16. case 5: return new NativeDate(y,m,d,h,i);
  17. case 6: return new NativeDate(y,m,d,h,i,s);
  18. case 7: return new NativeDate(y,y,m,d,h,i,s,j);
  19. }
  20. };
  21. date.now = NativeDate.now;
  22. date.UTC = NativeDate.UTC;
  23. return function() {
  24. Array.prototype.push.call(arguments, date);
  25. window.Date = date;
  26. f.apply(this, arguments);
  27. window.Date = NativeDate;
  28. };
  29. }
  30. document.addEventListener('DOMContentLoaded', function() {
  31. patch_date(function(Date){
  32. Date.now = () => {
  33. return new Date(2013, 2, 18).getTime();
  34. };
  35. $('input').datepicker({
  36. todayHighlight: true
  37. }).datepicker('show');
  38. })();
  39. });
  40. </script>
  41. </head>
  42. <body data-capture="input, .datepicker">
  43. <div class="row">
  44. <div class="col-sm-3">
  45. <input type="text" class="form-control" value="03/03/2013">
  46. </div>
  47. <div class="col-sm-offset-2 col-sm-3">
  48. <input type="text" class="form-control" value="03/18/2013">
  49. </div>
  50. </div>
  51. </body>
  52. </html>