How to use Date method in root

Best JavaScript code snippet using root

irregular-data-series.js

Source:irregular-data-series.js Github

copy

Full Screen

1var dataSeries = [2 [{3 "date": "2014-01-01",4 "value": 200000005 },6 {7 "date": "2014-01-02",8 "value": 103799789 },10 {11 "date": "2014-01-03",12 "value": 3049374913 },14 {15 "date": "2014-01-04",16 "value": 1078525017 },18 {19 "date": "2014-01-05",20 "value": 3390190421 },22 {23 "date": "2014-01-06",24 "value": 1157683825 },26 {27 "date": "2014-01-07",28 "value": 1441385429 },30 {31 "date": "2014-01-08",32 "value": 1517721133 },34 {35 "date": "2014-01-09",36 "value": 1662210037 },38 {39 "date": "2014-01-10",40 "value": 1738107241 },42 {43 "date": "2014-01-11",44 "value": 1880231045 },46 {47 "date": "2014-01-12",48 "value": 1553179049 },50 {51 "date": "2014-01-13",52 "value": 1574888153 },54 {55 "date": "2014-01-14",56 "value": 1870643757 },58 {59 "date": "2014-01-15",60 "value": 1975268561 },62 {63 "date": "2014-01-16",64 "value": 2101641865 },66 {67 "date": "2014-01-17",68 "value": 2562292469 },70 {71 "date": "2014-01-18",72 "value": 2533748073 },74 {75 "date": "2014-01-19",76 "value": 2225888277 },78 {79 "date": "2014-01-20",80 "value": 2382953881 },82 {83 "date": "2014-01-21",84 "value": 2424568985 },86 {87 "date": "2014-01-22",88 "value": 2642971189 },90 {91 "date": "2014-01-23",92 "value": 2625901793 },94 {95 "date": "2014-01-24",96 "value": 2539618397 },98 {99 "date": "2014-01-25",100 "value": 23107346101 },102 {103 "date": "2014-01-26",104 "value": 28659852105 },106 {107 "date": "2014-01-27",108 "value": 25270783109 },110 {111 "date": "2014-01-28",112 "value": 26270783113 },114 {115 "date": "2014-01-29",116 "value": 27270783117 },118 {119 "date": "2014-01-30",120 "value": 28270783121 },122 {123 "date": "2014-01-31",124 "value": 29270783125 },126 {127 "date": "2014-02-01",128 "value": 30270783129 },130 {131 "date": "2014-02-02",132 "value": 31270783133 },134 {135 "date": "2014-02-03",136 "value": 32270783137 },138 {139 "date": "2014-02-04",140 "value": 33270783141 },142 {143 "date": "2014-02-05",144 "value": 28270783145 },146 {147 "date": "2014-02-06",148 "value": 27270783149 },150 {151 "date": "2014-02-07",152 "value": 35270783153 },154 {155 "date": "2014-02-08",156 "value": 34270783157 },158 {159 "date": "2014-02-09",160 "value": 28270783161 },162 {163 "date": "2014-02-10",164 "value": 35270783165 },166 {167 "date": "2014-02-11",168 "value": 36270783169 },170 {171 "date": "2014-02-12",172 "value": 34127078173 },174 {175 "date": "2014-02-13",176 "value": 33124078177 },178 {179 "date": "2014-02-14",180 "value": 36227078181 },182 {183 "date": "2014-02-15",184 "value": 37827078185 },186 {187 "date": "2014-02-16",188 "value": 36427073189 },190 {191 "date": "2014-02-17",192 "value": 37570783193 },194 {195 "date": "2014-02-18",196 "value": 38627073197 },198 {199 "date": "2014-02-19",200 "value": 37727078201 },202 {203 "date": "2014-02-20",204 "value": 38827073205 },206 {207 "date": "2014-02-21",208 "value": 40927078209 },210 {211 "date": "2014-02-22",212 "value": 41027078213 },214 {215 "date": "2014-02-23",216 "value": 42127073217 },218 {219 "date": "2014-02-24",220 "value": 43220783221 },222 {223 "date": "2014-02-25",224 "value": 44327078225 },226 {227 "date": "2014-02-26",228 "value": 40427078229 },230 {231 "date": "2014-02-27",232 "value": 41027078233 },234 {235 "date": "2014-02-28",236 "value": 45627078237 },238 {239 "date": "2014-03-01",240 "value": 44727078241 },242 {243 "date": "2014-03-02",244 "value": 44227078245 },246 {247 "date": "2014-03-03",248 "value": 45227078249 },250 {251 "date": "2014-03-04",252 "value": 46027078253 },254 {255 "date": "2014-03-05",256 "value": 46927078257 },258 {259 "date": "2014-03-06",260 "value": 47027078261 },262 {263 "date": "2014-03-07",264 "value": 46227078265 },266 {267 "date": "2014-03-08",268 "value": 47027078269 },270 {271 "date": "2014-03-09",272 "value": 48027078273 },274 {275 "date": "2014-03-10",276 "value": 47027078277 },278 {279 "date": "2014-03-11",280 "value": 47027078281 },282 {283 "date": "2014-03-12",284 "value": 48017078285 },286 {287 "date": "2014-03-13",288 "value": 48077078289 },290 {291 "date": "2014-03-14",292 "value": 48087078293 },294 {295 "date": "2014-03-15",296 "value": 48017078297 },298 {299 "date": "2014-03-16",300 "value": 48047078301 },302 {303 "date": "2014-03-17",304 "value": 48067078305 },306 {307 "date": "2014-03-18",308 "value": 48077078309 },310 {311 "date": "2014-03-19",312 "value": 48027074313 },314 {315 "date": "2014-03-20",316 "value": 48927079317 },318 {319 "date": "2014-03-21",320 "value": 48727071321 },322 {323 "date": "2014-03-22",324 "value": 48127072325 },326 {327 "date": "2014-03-23",328 "value": 48527072329 },330 {331 "date": "2014-03-24",332 "value": 48627027333 },334 {335 "date": "2014-03-25",336 "value": 48027040337 },338 {339 "date": "2014-03-26",340 "value": 48027043341 },342 {343 "date": "2014-03-27",344 "value": 48057022345 },346 {347 "date": "2014-03-28",348 "value": 49057022349 },350 {351 "date": "2014-03-29",352 "value": 50057022353 },354 {355 "date": "2014-03-30",356 "value": 51057022357 },358 {359 "date": "2014-03-31",360 "value": 52057022361 },362 {363 "date": "2014-04-01",364 "value": 53057022365 },366 {367 "date": "2014-04-02",368 "value": 54057022369 },370 {371 "date": "2014-04-03",372 "value": 52057022373 },374 {375 "date": "2014-04-04",376 "value": 55057022377 },378 {379 "date": "2014-04-05",380 "value": 58270783381 },382 {383 "date": "2014-04-06",384 "value": 56270783385 },386 {387 "date": "2014-04-07",388 "value": 55270783389 },390 {391 "date": "2014-04-08",392 "value": 58270783393 },394 {395 "date": "2014-04-09",396 "value": 59270783397 },398 {399 "date": "2014-04-10",400 "value": 60270783401 },402 {403 "date": "2014-04-11",404 "value": 61270783405 },406 {407 "date": "2014-04-12",408 "value": 62270783409 },410 {411 "date": "2014-04-13",412 "value": 63270783413 },414 {415 "date": "2014-04-14",416 "value": 64270783417 },418 {419 "date": "2014-04-15",420 "value": 65270783421 },422 {423 "date": "2014-04-16",424 "value": 66270783425 },426 {427 "date": "2014-04-17",428 "value": 67270783429 },430 {431 "date": "2014-04-18",432 "value": 68270783433 },434 {435 "date": "2014-04-19",436 "value": 69270783437 },438 {439 "date": "2014-04-20",440 "value": 70270783441 },442 {443 "date": "2014-04-21",444 "value": 71270783445 },446 {447 "date": "2014-04-22",448 "value": 72270783449 },450 {451 "date": "2014-04-23",452 "value": 73270783453 },454 {455 "date": "2014-04-24",456 "value": 74270783457 },458 {459 "date": "2014-04-25",460 "value": 75270783461 },462 {463 "date": "2014-04-26",464 "value": 76660783465 },466 {467 "date": "2014-04-27",468 "value": 77270783469 },470 {471 "date": "2014-04-28",472 "value": 78370783473 },474 {475 "date": "2014-04-29",476 "value": 79470783477 },478 {479 "date": "2014-04-30",480 "value": 80170783481 }482 ],483 [{484 "date": "2014-01-01",485 "value": 150000000486 },487 {488 "date": "2014-01-02",489 "value": 160379978490 },491 {492 "date": "2014-01-03",493 "value": 170493749494 },495 {496 "date": "2014-01-04",497 "value": 160785250498 },499 {500 "date": "2014-01-05",501 "value": 167391904502 },503 {504 "date": "2014-01-06",505 "value": 161576838506 },507 {508 "date": "2014-01-07",509 "value": 161413854510 },511 {512 "date": "2014-01-08",513 "value": 152177211514 },515 {516 "date": "2014-01-09",517 "value": 140762210518 },519 {520 "date": "2014-01-10",521 "value": 144381072522 },523 {524 "date": "2014-01-11",525 "value": 154352310526 },527 {528 "date": "2014-01-12",529 "value": 165531790530 },531 {532 "date": "2014-01-13",533 "value": 175748881534 },535 {536 "date": "2014-01-14",537 "value": 187064037538 },539 {540 "date": "2014-01-15",541 "value": 197520685542 },543 {544 "date": "2014-01-16",545 "value": 210176418546 },547 {548 "date": "2014-01-17",549 "value": 196122924550 },551 {552 "date": "2014-01-18",553 "value": 207337480554 },555 {556 "date": "2014-01-19",557 "value": 200258882558 },559 {560 "date": "2014-01-20",561 "value": 186829538562 },563 {564 "date": "2014-01-21",565 "value": 192456897566 },567 {568 "date": "2014-01-22",569 "value": 204299711570 },571 {572 "date": "2014-01-23",573 "value": 192759017574 },575 {576 "date": "2014-01-24",577 "value": 203596183578 },579 {580 "date": "2014-01-25",581 "value": 208107346582 },583 {584 "date": "2014-01-26",585 "value": 196359852586 },587 {588 "date": "2014-01-27",589 "value": 192570783590 },591 {592 "date": "2014-01-28",593 "value": 177967768594 },595 {596 "date": "2014-01-29",597 "value": 190632803598 },599 {600 "date": "2014-01-30",601 "value": 203725316602 },603 {604 "date": "2014-01-31",605 "value": 218226177606 },607 {608 "date": "2014-02-01",609 "value": 210698669610 },611 {612 "date": "2014-02-02",613 "value": 217640656614 },615 {616 "date": "2014-02-03",617 "value": 216142362618 },619 {620 "date": "2014-02-04",621 "value": 201410971622 },623 {624 "date": "2014-02-05",625 "value": 196704289626 },627 {628 "date": "2014-02-06",629 "value": 190436945630 },631 {632 "date": "2014-02-07",633 "value": 178891686634 },635 {636 "date": "2014-02-08",637 "value": 171613962638 },639 {640 "date": "2014-02-09",641 "value": 157579773642 },643 {644 "date": "2014-02-10",645 "value": 158677098646 },647 {648 "date": "2014-02-11",649 "value": 147129977650 },651 {652 "date": "2014-02-12",653 "value": 151561876654 },655 {656 "date": "2014-02-13",657 "value": 151627421658 },659 {660 "date": "2014-02-14",661 "value": 143543872662 },663 {664 "date": "2014-02-15",665 "value": 136581057666 },667 {668 "date": "2014-02-16",669 "value": 135560715670 },671 {672 "date": "2014-02-17",673 "value": 122625263674 },675 {676 "date": "2014-02-18",677 "value": 112091484678 },679 {680 "date": "2014-02-19",681 "value": 98810329682 },683 {684 "date": "2014-02-20",685 "value": 99882912686 },687 {688 "date": "2014-02-21",689 "value": 94943095690 },691 {692 "date": "2014-02-22",693 "value": 104875743694 },695 {696 "date": "2014-02-23",697 "value": 116383678698 },699 {700 "date": "2014-02-24",701 "value": 125028841702 },703 {704 "date": "2014-02-25",705 "value": 123967310706 },707 {708 "date": "2014-02-26",709 "value": 133167029710 },711 {712 "date": "2014-02-27",713 "value": 128577263714 },715 {716 "date": "2014-02-28",717 "value": 115836969718 },719 {720 "date": "2014-03-01",721 "value": 119264529722 },723 {724 "date": "2014-03-02",725 "value": 109363374726 },727 {728 "date": "2014-03-03",729 "value": 113985628730 },731 {732 "date": "2014-03-04",733 "value": 114650999734 },735 {736 "date": "2014-03-05",737 "value": 110866108738 },739 {740 "date": "2014-03-06",741 "value": 96473454742 },743 {744 "date": "2014-03-07",745 "value": 104075886746 },747 {748 "date": "2014-03-08",749 "value": 103568384750 },751 {752 "date": "2014-03-09",753 "value": 101534883754 },755 {756 "date": "2014-03-10",757 "value": 115825447758 },759 {760 "date": "2014-03-11",761 "value": 126133916762 },763 {764 "date": "2014-03-12",765 "value": 116502109766 },767 {768 "date": "2014-03-13",769 "value": 130169411770 },771 {772 "date": "2014-03-14",773 "value": 124296886774 },775 {776 "date": "2014-03-15",777 "value": 126347399778 },779 {780 "date": "2014-03-16",781 "value": 131483669782 },783 {784 "date": "2014-03-17",785 "value": 142811333786 },787 {788 "date": "2014-03-18",789 "value": 129675396790 },791 {792 "date": "2014-03-19",793 "value": 115514483794 },795 {796 "date": "2014-03-20",797 "value": 117630630798 },799 {800 "date": "2014-03-21",801 "value": 122340239802 },803 {804 "date": "2014-03-22",805 "value": 132349091806 },807 {808 "date": "2014-03-23",809 "value": 125613305810 },811 {812 "date": "2014-03-24",813 "value": 135592466814 },815 {816 "date": "2014-03-25",817 "value": 123408762818 },819 {820 "date": "2014-03-26",821 "value": 111991454822 },823 {824 "date": "2014-03-27",825 "value": 116123955826 },827 {828 "date": "2014-03-28",829 "value": 112817214830 },831 {832 "date": "2014-03-29",833 "value": 113029590834 },835 {836 "date": "2014-03-30",837 "value": 108753398838 },839 {840 "date": "2014-03-31",841 "value": 99383763842 },843 {844 "date": "2014-04-01",845 "value": 100151737846 },847 {848 "date": "2014-04-02",849 "value": 94985209850 },851 {852 "date": "2014-04-03",853 "value": 82913669854 },855 {856 "date": "2014-04-04",857 "value": 78748268858 },859 {860 "date": "2014-04-05",861 "value": 63829135862 },863 {864 "date": "2014-04-06",865 "value": 78694727866 },867 {868 "date": "2014-04-07",869 "value": 80868994870 },871 {872 "date": "2014-04-08",873 "value": 93799013874 },875 {876 "date": "2014-04-09",877 "value": 99042416878 },879 {880 "date": "2014-04-10",881 "value": 97298692882 },883 {884 "date": "2014-04-11",885 "value": 83353499886 },887 {888 "date": "2014-04-12",889 "value": 71248129890 },891 {892 "date": "2014-04-13",893 "value": 75253744894 },895 {896 "date": "2014-04-14",897 "value": 68976648898 },899 {900 "date": "2014-04-15",901 "value": 71002284902 },903 {904 "date": "2014-04-16",905 "value": 75052401906 },907 {908 "date": "2014-04-17",909 "value": 83894030910 },911 {912 "date": "2014-04-18",913 "value": 90236528914 },915 {916 "date": "2014-04-19",917 "value": 99739114918 },919 {920 "date": "2014-04-20",921 "value": 96407136922 },923 {924 "date": "2014-04-21",925 "value": 108323177926 },927 {928 "date": "2014-04-22",929 "value": 101578914930 },931 {932 "date": "2014-04-23",933 "value": 115877608934 },935 {936 "date": "2014-04-24",937 "value": 112088857938 },939 {940 "date": "2014-04-25",941 "value": 112071353942 },943 {944 "date": "2014-04-26",945 "value": 101790062946 },947 {948 "date": "2014-04-27",949 "value": 115003761950 },951 {952 "date": "2014-04-28",953 "value": 120457727954 },955 {956 "date": "2014-04-29",957 "value": 118253926958 },959 {960 "date": "2014-04-30",961 "value": 117956992962 }963 ],964 [{965 "date": "2014-01-01",966 "value": 50000000967 },968 {969 "date": "2014-01-02",970 "value": 60379978971 },972 {973 "date": "2014-01-03",974 "value": 40493749975 },976 {977 "date": "2014-01-04",978 "value": 60785250979 },980 {981 "date": "2014-01-05",982 "value": 67391904983 },984 {985 "date": "2014-01-06",986 "value": 61576838987 },988 {989 "date": "2014-01-07",990 "value": 61413854991 },992 {993 "date": "2014-01-08",994 "value": 82177211995 },996 {997 "date": "2014-01-09",998 "value": 103762210999 },1000 {1001 "date": "2014-01-10",1002 "value": 843810721003 },1004 {1005 "date": "2014-01-11",1006 "value": 543523101007 },1008 {1009 "date": "2014-01-12",1010 "value": 655317901011 },1012 {1013 "date": "2014-01-13",1014 "value": 757488811015 },1016 {1017 "date": "2014-01-14",1018 "value": 470640371019 },1020 {1021 "date": "2014-01-15",1022 "value": 675206851023 },1024 {1025 "date": "2014-01-16",1026 "value": 601764181027 },1028 {1029 "date": "2014-01-17",1030 "value": 661229241031 },1032 {1033 "date": "2014-01-18",1034 "value": 573374801035 },1036 {1037 "date": "2014-01-19",1038 "value": 1002588821039 },1040 {1041 "date": "2014-01-20",1042 "value": 468295381043 },1044 {1045 "date": "2014-01-21",1046 "value": 924568971047 },1048 {1049 "date": "2014-01-22",1050 "value": 942997111051 },1052 {1053 "date": "2014-01-23",1054 "value": 627590171055 },1056 {1057 "date": "2014-01-24",1058 "value": 1035961831059 },1060 {1061 "date": "2014-01-25",1062 "value": 1081073461063 },1064 {1065 "date": "2014-01-26",1066 "value": 663598521067 },1068 {1069 "date": "2014-01-27",1070 "value": 625707831071 },1072 {1073 "date": "2014-01-28",1074 "value": 779677681075 },1076 {1077 "date": "2014-01-29",1078 "value": 606328031079 },1080 {1081 "date": "2014-01-30",1082 "value": 1037253161083 },1084 {1085 "date": "2014-01-31",1086 "value": 982261771087 },1088 {1089 "date": "2014-02-01",1090 "value": 606986691091 },1092 {1093 "date": "2014-02-02",1094 "value": 676406561095 },1096 {1097 "date": "2014-02-03",1098 "value": 661423621099 },1100 {1101 "date": "2014-02-04",1102 "value": 1014109711103 },1104 {1105 "date": "2014-02-05",1106 "value": 667042891107 },1108 {1109 "date": "2014-02-06",1110 "value": 604369451111 },1112 {1113 "date": "2014-02-07",1114 "value": 788916861115 },1116 {1117 "date": "2014-02-08",1118 "value": 716139621119 },1120 {1121 "date": "2014-02-09",1122 "value": 1075797731123 },1124 {1125 "date": "2014-02-10",1126 "value": 586770981127 },1128 {1129 "date": "2014-02-11",1130 "value": 871299771131 },1132 {1133 "date": "2014-02-12",1134 "value": 515618761135 },1136 {1137 "date": "2014-02-13",1138 "value": 516274211139 },1140 {1141 "date": "2014-02-14",1142 "value": 835438721143 },1144 {1145 "date": "2014-02-15",1146 "value": 665810571147 },1148 {1149 "date": "2014-02-16",1150 "value": 655607151151 },1152 {1153 "date": "2014-02-17",1154 "value": 626252631155 },1156 {1157 "date": "2014-02-18",1158 "value": 920914841159 },1160 {1161 "date": "2014-02-19",1162 "value": 488103291163 },1164 {1165 "date": "2014-02-20",1166 "value": 498829121167 },1168 {1169 "date": "2014-02-21",1170 "value": 449430951171 },1172 {1173 "date": "2014-02-22",1174 "value": 1048757431175 },1176 {1177 "date": "2014-02-23",1178 "value": 963836781179 },1180 {1181 "date": "2014-02-24",1182 "value": 1050288411183 },1184 {1185 "date": "2014-02-25",1186 "value": 639673101187 },1188 {1189 "date": "2014-02-26",1190 "value": 631670291191 },1192 {1193 "date": "2014-02-27",1194 "value": 685772631195 },1196 {1197 "date": "2014-02-28",1198 "value": 958369691199 },1200 {1201 "date": "2014-03-01",1202 "value": 992645291203 },1204 {1205 "date": "2014-03-02",1206 "value": 1093633741207 },1208 {1209 "date": "2014-03-03",1210 "value": 939856281211 },1212 {1213 "date": "2014-03-04",1214 "value": 946509991215 },1216 {1217 "date": "2014-03-05",1218 "value": 908661081219 },1220 {1221 "date": "2014-03-06",1222 "value": 464734541223 },1224 {1225 "date": "2014-03-07",1226 "value": 840758861227 },1228 {1229 "date": "2014-03-08",1230 "value": 1035683841231 },1232 {1233 "date": "2014-03-09",1234 "value": 1015348831235 },1236 {1237 "date": "2014-03-10",1238 "value": 958254471239 },1240 {1241 "date": "2014-03-11",1242 "value": 661339161243 },1244 {1245 "date": "2014-03-12",1246 "value": 965021091247 },1248 {1249 "date": "2014-03-13",1250 "value": 801694111251 },1252 {1253 "date": "2014-03-14",1254 "value": 842968861255 },1256 {1257 "date": "2014-03-15",1258 "value": 863473991259 },1260 {1261 "date": "2014-03-16",1262 "value": 314836691263 },1264 {1265 "date": "2014-03-17",1266 "value": 828113331267 },1268 {1269 "date": "2014-03-18",1270 "value": 896753961271 },1272 {1273 "date": "2014-03-19",1274 "value": 955144831275 },1276 {1277 "date": "2014-03-20",1278 "value": 976306301279 },1280 {1281 "date": "2014-03-21",1282 "value": 623402391283 },1284 {1285 "date": "2014-03-22",1286 "value": 623490911287 },1288 {1289 "date": "2014-03-23",1290 "value": 656133051291 },1292 {1293 "date": "2014-03-24",1294 "value": 655924661295 },1296 {1297 "date": "2014-03-25",1298 "value": 634087621299 },1300 {1301 "date": "2014-03-26",1302 "value": 919914541303 },1304 {1305 "date": "2014-03-27",1306 "value": 961239551307 },1308 {1309 "date": "2014-03-28",1310 "value": 928172141311 },1312 {1313 "date": "2014-03-29",1314 "value": 930295901315 },1316 {1317 "date": "2014-03-30",1318 "value": 1087533981319 },1320 {1321 "date": "2014-03-31",1322 "value": 493837631323 },1324 {1325 "date": "2014-04-01",1326 "value": 1001517371327 },1328 {1329 "date": "2014-04-02",1330 "value": 449852091331 },1332 {1333 "date": "2014-04-03",1334 "value": 529136691335 },1336 {1337 "date": "2014-04-04",1338 "value": 487482681339 },1340 {1341 "date": "2014-04-05",1342 "value": 238291351343 },1344 {1345 "date": "2014-04-06",1346 "value": 586947271347 },1348 {1349 "date": "2014-04-07",1350 "value": 508689941351 },1352 {1353 "date": "2014-04-08",1354 "value": 437990131355 },1356 {1357 "date": "2014-04-09",1358 "value": 40424161359 },1360 {1361 "date": "2014-04-10",1362 "value": 472986921363 },1364 {1365 "date": "2014-04-11",1366 "value": 533534991367 },1368 {1369 "date": "2014-04-12",1370 "value": 712481291371 },1372 {1373 "date": "2014-04-13",1374 "value": 752537441375 },1376 {1377 "date": "2014-04-14",1378 "value": 689766481379 },1380 {1381 "date": "2014-04-15",1382 "value": 710022841383 },1384 {1385 "date": "2014-04-16",1386 "value": 750524011387 },1388 {1389 "date": "2014-04-17",1390 "value": 838940301391 },1392 {1393 "date": "2014-04-18",1394 "value": 502365281395 },1396 {1397 "date": "2014-04-19",1398 "value": 597391141399 },1400 {1401 "date": "2014-04-20",1402 "value": 564071361403 },1404 {1405 "date": "2014-04-21",1406 "value": 1083231771407 },1408 {1409 "date": "2014-04-22",1410 "value": 1015789141411 },1412 {1413 "date": "2014-04-23",1414 "value": 958776081415 },1416 {1417 "date": "2014-04-24",1418 "value": 620888571419 },1420 {1421 "date": "2014-04-25",1422 "value": 920713531423 },1424 {1425 "date": "2014-04-26",1426 "value": 817900621427 },1428 {1429 "date": "2014-04-27",1430 "value": 1050037611431 },1432 {1433 "date": "2014-04-28",1434 "value": 1004577271435 },1436 {1437 "date": "2014-04-29",1438 "value": 982539261439 },1440 {1441 "date": "2014-04-30",1442 "value": 679569921443 }1444 ]...

Full Screen

Full Screen

daterange.js

Source:daterange.js Github

copy

Full Screen

...49/**50 * The first possible day, as far as this class is concerned.51 * @type {goog.date.Date}52 */53goog.date.DateRange.MINIMUM_DATE = new goog.date.Date(0, 0, 1);54/**55 * The last possible day, as far as this class is concerned.56 * @type {goog.date.Date}57 */58goog.date.DateRange.MAXIMUM_DATE = new goog.date.Date(9999, 11, 31);59/**60 * @return {goog.date.Date} The first date in the range.61 */62goog.date.DateRange.prototype.getStartDate = function() {63 return this.startDate_;64};65/**66 * @return {goog.date.Date} The last date in the range.67 */68goog.date.DateRange.prototype.getEndDate = function() {69 return this.endDate_;70};71/**72 * Tests if a date falls within this range.73 *74 * @param {goog.date.Date} date The date to test.75 * @return {boolean} Whether the date is in the range.76 */77goog.date.DateRange.prototype.contains = function(date) {78 return date.valueOf() >= this.startDate_.valueOf() &&79 date.valueOf() <= this.endDate_.valueOf();80};81/**82 * @return {!goog.date.DateRange.Iterator} An iterator over the date range.83 */84goog.date.DateRange.prototype.iterator = function() {85 return new goog.date.DateRange.Iterator(this);86};87/**88 * Tests two {@link goog.date.DateRange} objects for equality.89 * @param {goog.date.DateRange} a A date range.90 * @param {goog.date.DateRange} b A date range.91 * @return {boolean} Whether |a| is the same range as |b|.92 */93goog.date.DateRange.equals = function(a, b) {94 // Test for same object reference; type conversion is irrelevant.95 if (a === b) {96 return true;97 }98 if (a == null || b == null) {99 return false;100 }101 return a.startDate_.equals(b.startDate_) && a.endDate_.equals(b.endDate_);102};103/**104 * Calculates a date that is a number of days after a date. Does not modify its105 * input.106 * @param {goog.date.Date} date The input date.107 * @param {number} offset Number of days.108 * @return {!goog.date.Date} The date that is |offset| days after |date|.109 * @private110 */111goog.date.DateRange.offsetInDays_ = function(date, offset) {112 var newDate = date.clone();113 newDate.add(new goog.date.Interval(goog.date.Interval.DAYS, offset));114 return newDate;115};116/**117 * Calculates a date that is a number of months after the first day in the118 * month that contains its input. Does not modify its input.119 * @param {goog.date.Date} date The input date.120 * @param {number} offset Number of months.121 * @return {!goog.date.Date} The date that is |offset| months after the first122 * day in the month that contains |date|.123 * @private124 */125goog.date.DateRange.offsetInMonths_ = function(date, offset) {126 var newDate = date.clone();127 newDate.setDate(1);128 newDate.add(new goog.date.Interval(goog.date.Interval.MONTHS, offset));129 return newDate;130};131/**132 * Returns the range from yesterday to yesterday.133 * @param {goog.date.Date=} opt_today The date to consider today.134 * Defaults to today.135 * @return {!goog.date.DateRange} The range that includes only yesterday.136 */137goog.date.DateRange.yesterday = function(opt_today) {138 var today = goog.date.DateRange.cloneOrCreate_(opt_today);139 var yesterday = goog.date.DateRange.offsetInDays_(today, -1);140 return new goog.date.DateRange(yesterday, yesterday.clone());141};142/**143 * Returns the range from today to today.144 * @param {goog.date.Date=} opt_today The date to consider today.145 * Defaults to today.146 * @return {!goog.date.DateRange} The range that includes only today.147 */148goog.date.DateRange.today = function(opt_today) {149 var today = goog.date.DateRange.cloneOrCreate_(opt_today);150 return new goog.date.DateRange(today, today.clone());151};152/**153 * Returns the range that includes the seven days that end yesterday.154 * @param {goog.date.Date=} opt_today The date to consider today.155 * Defaults to today.156 * @return {!goog.date.DateRange} The range that includes the seven days that157 * end yesterday.158 */159goog.date.DateRange.last7Days = function(opt_today) {160 var today = goog.date.DateRange.cloneOrCreate_(opt_today);161 var yesterday = goog.date.DateRange.offsetInDays_(today, -1);162 return new goog.date.DateRange(163 goog.date.DateRange.offsetInDays_(today, -7), yesterday);164};165/**166 * Returns the range that starts the first of this month and ends the last day167 * of this month.168 * @param {goog.date.Date=} opt_today The date to consider today.169 * Defaults to today.170 * @return {!goog.date.DateRange} The range that starts the first of this month171 * and ends the last day of this month.172 */173goog.date.DateRange.thisMonth = function(opt_today) {174 var today = goog.date.DateRange.cloneOrCreate_(opt_today);175 return new goog.date.DateRange(176 goog.date.DateRange.offsetInMonths_(today, 0),177 goog.date.DateRange.offsetInDays_(178 goog.date.DateRange.offsetInMonths_(today, 1), -1));179};180/**181 * Returns the range that starts the first of last month and ends the last day182 * of last month.183 * @param {goog.date.Date=} opt_today The date to consider today.184 * Defaults to today.185 * @return {!goog.date.DateRange} The range that starts the first of last month186 * and ends the last day of last month.187 */188goog.date.DateRange.lastMonth = function(opt_today) {189 var today = goog.date.DateRange.cloneOrCreate_(opt_today);190 return new goog.date.DateRange(191 goog.date.DateRange.offsetInMonths_(today, -1),192 goog.date.DateRange.offsetInDays_(193 goog.date.DateRange.offsetInMonths_(today, 0), -1));194};195/**196 * Returns the seven-day range that starts on the first day of the week197 * (see {@link goog.i18n.DateTimeSymbols.FIRSTDAYOFWEEK}) on or before today.198 * @param {goog.date.Date=} opt_today The date to consider today.199 * Defaults to today.200 * @return {!goog.date.DateRange} The range that starts the Monday on or before201 * today and ends the Sunday on or after today.202 */203goog.date.DateRange.thisWeek = function(opt_today) {204 var today = goog.date.DateRange.cloneOrCreate_(opt_today);205 var iso = today.getIsoWeekday();206 var firstDay = today.getFirstDayOfWeek();207 var i18nFirstDay = (iso >= firstDay) ? iso - firstDay : iso + (7 - firstDay);208 var start = goog.date.DateRange.offsetInDays_(today, -i18nFirstDay);209 var end = goog.date.DateRange.offsetInDays_(start, 6);210 return new goog.date.DateRange(start, end);211};212/**213 * Returns the seven-day range that ends the day before the first day of214 * the week (see {@link goog.i18n.DateTimeSymbols.FIRSTDAYOFWEEK}) that215 * contains today.216 * @param {goog.date.Date=} opt_today The date to consider today.217 * Defaults to today.218 * @return {!goog.date.DateRange} The range that starts seven days before the219 * Monday on or before today and ends the Sunday on or before yesterday.220 */221goog.date.DateRange.lastWeek = function(opt_today) {222 var thisWeek = goog.date.DateRange.thisWeek(opt_today);223 var start = goog.date.DateRange.offsetInDays_(thisWeek.getStartDate(), -7);224 var end = goog.date.DateRange.offsetInDays_(thisWeek.getEndDate(), -7);225 return new goog.date.DateRange(start, end);226};227/**228 * Returns the range that starts seven days before the Monday on or before229 * today and ends the Friday before today.230 * @param {goog.date.Date=} opt_today The date to consider today.231 * Defaults to today.232 * @return {!goog.date.DateRange} The range that starts seven days before the233 * Monday on or before today and ends the Friday before today.234 */235goog.date.DateRange.lastBusinessWeek = function(opt_today) {236 // TODO(user): should be i18nized.237 var today = goog.date.DateRange.cloneOrCreate_(opt_today);238 var start =239 goog.date.DateRange.offsetInDays_(today, -7 - today.getIsoWeekday());240 var end = goog.date.DateRange.offsetInDays_(start, 4);241 return new goog.date.DateRange(start, end);242};243/**244 * Returns the range that includes all days between January 1, 1900 and245 * December 31, 9999.246 * @param {goog.date.Date=} opt_today The date to consider today.247 * Defaults to today.248 * @return {!goog.date.DateRange} The range that includes all days between249 * January 1, 1900 and December 31, 9999.250 */251goog.date.DateRange.allTime = function(opt_today) {252 return new goog.date.DateRange(253 goog.date.DateRange.MINIMUM_DATE, goog.date.DateRange.MAXIMUM_DATE);254};255/**256 * Standard date range keys. Equivalent to the enum IDs in257 * DateRange.java http://go/datarange.java258 *259 * @enum {string}260 */261goog.date.DateRange.StandardDateRangeKeys = {262 YESTERDAY: 'yesterday',263 TODAY: 'today',264 LAST_7_DAYS: 'last7days',265 THIS_MONTH: 'thismonth',266 LAST_MONTH: 'lastmonth',267 THIS_WEEK: 'thisweek',268 LAST_WEEK: 'lastweek',269 LAST_BUSINESS_WEEK: 'lastbusinessweek',270 ALL_TIME: 'alltime'271};272/**273 * @param {string} dateRangeKey A standard date range key.274 * @param {goog.date.Date=} opt_today The date to consider today.275 * Defaults to today.276 * @return {!goog.date.DateRange} The date range that corresponds to that key.277 * @throws {Error} If no standard date range with that key exists.278 */279goog.date.DateRange.standardDateRange = function(dateRangeKey, opt_today) {280 switch (dateRangeKey) {281 case goog.date.DateRange.StandardDateRangeKeys.YESTERDAY:282 return goog.date.DateRange.yesterday(opt_today);283 case goog.date.DateRange.StandardDateRangeKeys.TODAY:284 return goog.date.DateRange.today(opt_today);285 case goog.date.DateRange.StandardDateRangeKeys.LAST_7_DAYS:286 return goog.date.DateRange.last7Days(opt_today);287 case goog.date.DateRange.StandardDateRangeKeys.THIS_MONTH:288 return goog.date.DateRange.thisMonth(opt_today);289 case goog.date.DateRange.StandardDateRangeKeys.LAST_MONTH:290 return goog.date.DateRange.lastMonth(opt_today);291 case goog.date.DateRange.StandardDateRangeKeys.THIS_WEEK:292 return goog.date.DateRange.thisWeek(opt_today);293 case goog.date.DateRange.StandardDateRangeKeys.LAST_WEEK:294 return goog.date.DateRange.lastWeek(opt_today);295 case goog.date.DateRange.StandardDateRangeKeys.LAST_BUSINESS_WEEK:296 return goog.date.DateRange.lastBusinessWeek(opt_today);297 case goog.date.DateRange.StandardDateRangeKeys.ALL_TIME:298 return goog.date.DateRange.allTime(opt_today);299 default:300 throw Error('no such date range key: ' + dateRangeKey);301 }302};303/**304 * Clones or creates new.305 * @param {goog.date.Date=} opt_today The date to consider today.306 * Defaults to today.307 * @return {!goog.date.Date} cloned or new.308 * @private309 */310goog.date.DateRange.cloneOrCreate_ = function(opt_today) {311 return opt_today ? opt_today.clone() : new goog.date.Date();312};313/**314 * Creates an iterator over the dates in a {@link goog.date.DateRange}.315 * @constructor316 * @struct317 * @extends {goog.iter.Iterator<goog.date.Date>}318 * @param {goog.date.DateRange} dateRange The date range to iterate.319 * @final320 */321goog.date.DateRange.Iterator = function(dateRange) {322 /**323 * The next date.324 * @type {goog.date.Date}325 * @private326 */327 this.nextDate_ = dateRange.getStartDate().clone();328 /**329 * The end date, expressed as an integer: YYYYMMDD.330 * @type {number}331 * @private332 */333 this.endDate_ = Number(dateRange.getEndDate().toIsoString());334};335goog.inherits(goog.date.DateRange.Iterator, goog.iter.Iterator);336/** @override */337goog.date.DateRange.Iterator.prototype.next = function() {338 if (Number(this.nextDate_.toIsoString()) > this.endDate_) {339 throw goog.iter.StopIteration;340 }341 var rv = this.nextDate_.clone();342 this.nextDate_.add(new goog.date.Interval(goog.date.Interval.DAYS, 1));343 return rv;...

Full Screen

Full Screen

datacube.py

Source:datacube.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2from __future__ import absolute_import, unicode_literals3import datetime4import six5from wechatpy.client.api.base import BaseWeChatAPI6class WeChatDataCube(BaseWeChatAPI):7 API_BASE_URL = 'https://api.weixin.qq.com/datacube/'8 @classmethod9 def _to_date_str(cls, date):10 if isinstance(date, (datetime.datetime, datetime.date)):11 return date.strftime('%Y-%m-%d')12 elif isinstance(date, six.string_types):13 return date14 else:15 raise ValueError('Can not convert %s type to str', type(date))16 def get_user_summary(self, begin_date, end_date):17 """18 获取用户增减数据19 详情请参考20 http://mp.weixin.qq.com/wiki/3/ecfed6e1a0a03b5f35e5efac98e864b7.html21 :param begin_date: 起始日期22 :param end_date: 结束日期23 :return: 统计数据列表24 """25 res = self._post(26 'getusersummary',27 data={28 'begin_date': self._to_date_str(begin_date),29 'end_date': self._to_date_str(end_date)30 }31 )32 return res['list']33 def get_user_cumulate(self, begin_date, end_date):34 """35 获取累计用户数据36 详情请参考37 http://mp.weixin.qq.com/wiki/3/ecfed6e1a0a03b5f35e5efac98e864b7.html38 :param begin_date: 起始日期39 :param end_date: 结束日期40 :return: 统计数据列表41 """42 res = self._post(43 'getusercumulate',44 data={45 'begin_date': self._to_date_str(begin_date),46 'end_date': self._to_date_str(end_date)47 },48 result_processor=lambda x: x['list']49 )50 return res51 def get_interface_summary(self, begin_date, end_date):52 """53 获取接口分析数据54 详情请参考55 http://mp.weixin.qq.com/wiki/8/30ed81ae38cf4f977194bf1a5db73668.html56 :param begin_date: 起始日期57 :param end_date: 结束日期58 :return: 统计数据列表59 """60 res = self._post(61 'getinterfacesummary',62 data={63 'begin_date': self._to_date_str(begin_date),64 'end_date': self._to_date_str(end_date)65 },66 result_processor=lambda x: x['list']67 )68 return res69 def get_interface_summary_hour(self, begin_date, end_date):70 """71 获取接口分析分时数据72 详情请参考73 http://mp.weixin.qq.com/wiki/8/30ed81ae38cf4f977194bf1a5db73668.html74 :param begin_date: 起始日期75 :param end_date: 结束日期76 :return: 统计数据列表77 """78 res = self._post(79 'getinterfacesummaryhour',80 data={81 'begin_date': self._to_date_str(begin_date),82 'end_date': self._to_date_str(end_date)83 },84 result_processor=lambda x: x['list']85 )86 return res87 def get_article_summary(self, begin_date, end_date):88 """89 获取图文群发每日数据90 详情请参考91 http://mp.weixin.qq.com/wiki/8/c0453610fb5131d1fcb17b4e87c82050.html92 :param begin_date: 起始日期93 :param end_date: 结束日期94 :return: 统计数据列表95 """96 res = self._post(97 'getarticlesummary',98 data={99 'begin_date': self._to_date_str(begin_date),100 'end_date': self._to_date_str(end_date)101 },102 result_processor=lambda x: x['list']103 )104 return res105 def get_article_total(self, begin_date, end_date):106 """107 获取图文群发总数据108 详情请参考109 http://mp.weixin.qq.com/wiki/8/c0453610fb5131d1fcb17b4e87c82050.html110 :param begin_date: 起始日期111 :param end_date: 结束日期112 :return: 统计数据列表113 """114 res = self._post(115 'getarticletotal',116 data={117 'begin_date': self._to_date_str(begin_date),118 'end_date': self._to_date_str(end_date)119 },120 result_processor=lambda x: x['list']121 )122 return res123 def get_user_read(self, begin_date, end_date):124 """125 获取图文统计数据126 详情请参考127 http://mp.weixin.qq.com/wiki/8/c0453610fb5131d1fcb17b4e87c82050.html128 :param begin_date: 起始日期129 :param end_date: 结束日期130 :return: 统计数据列表131 """132 res = self._post(133 'getuserread',134 data={135 'begin_date': self._to_date_str(begin_date),136 'end_date': self._to_date_str(end_date)137 },138 result_processor=lambda x: x['list']139 )140 return res141 def get_user_read_hour(self, begin_date, end_date):142 """143 获取图文分时统计数据144 详情请参考145 http://mp.weixin.qq.com/wiki/8/c0453610fb5131d1fcb17b4e87c82050.html146 :param begin_date: 起始日期147 :param end_date: 结束日期148 :return: 统计数据列表149 """150 res = self._post(151 'getuserreadhour',152 data={153 'begin_date': self._to_date_str(begin_date),154 'end_date': self._to_date_str(end_date)155 },156 result_processor=lambda x: x['list']157 )158 return res159 def get_user_share(self, begin_date, end_date):160 """161 获取图文分享转发数据162 详情请参考163 http://mp.weixin.qq.com/wiki/8/c0453610fb5131d1fcb17b4e87c82050.html164 :param begin_date: 起始日期165 :param end_date: 结束日期166 :return: 统计数据列表167 """168 res = self._post(169 'getusershare',170 data={171 'begin_date': self._to_date_str(begin_date),172 'end_date': self._to_date_str(end_date)173 },174 result_processor=lambda x: x['list']175 )176 return res177 def get_user_share_hour(self, begin_date, end_date):178 """179 获取图文分享转发分时数据180 详情请参考181 http://mp.weixin.qq.com/wiki/8/c0453610fb5131d1fcb17b4e87c82050.html182 :param begin_date: 起始日期183 :param end_date: 结束日期184 :return: 统计数据列表185 """186 res = self._post(187 'getusersharehour',188 data={189 'begin_date': self._to_date_str(begin_date),190 'end_date': self._to_date_str(end_date)191 },192 result_processor=lambda x: x['list']193 )194 return res195 def get_upstream_msg(self, begin_date, end_date):196 """197 获取消息发送概况数据198 详情请参考199 http://mp.weixin.qq.com/wiki/12/32d42ad542f2e4fc8a8aa60e1bce9838.html200 :param begin_date: 起始日期201 :param end_date: 结束日期202 :return: 统计数据列表203 """204 res = self._post(205 'getupstreammsg',206 data={207 'begin_date': self._to_date_str(begin_date),208 'end_date': self._to_date_str(end_date)209 },210 result_processor=lambda x: x['list']211 )212 return res213 def get_upstream_msg_hour(self, begin_date, end_date):214 """215 获取消息发送分时数据216 详情请参考217 http://mp.weixin.qq.com/wiki/12/32d42ad542f2e4fc8a8aa60e1bce9838.html218 :param begin_date: 起始日期219 :param end_date: 结束日期220 :return: 统计数据列表221 """222 res = self._post(223 'getupstreammsghour',224 data={225 'begin_date': self._to_date_str(begin_date),226 'end_date': self._to_date_str(end_date)227 },228 result_processor=lambda x: x['list']229 )230 return res231 def get_upstream_msg_week(self, begin_date, end_date):232 """233 获取消息发送周数据234 详情请参考235 http://mp.weixin.qq.com/wiki/12/32d42ad542f2e4fc8a8aa60e1bce9838.html236 :param begin_date: 起始日期237 :param end_date: 结束日期238 :return: 统计数据列表239 """240 res = self._post(241 'getupstreammsgweek',242 data={243 'begin_date': self._to_date_str(begin_date),244 'end_date': self._to_date_str(end_date)245 },246 result_processor=lambda x: x['list']247 )248 return res249 def get_upstream_msg_month(self, begin_date, end_date):250 """251 获取消息发送月数据252 详情请参考253 http://mp.weixin.qq.com/wiki/12/32d42ad542f2e4fc8a8aa60e1bce9838.html254 :param begin_date: 起始日期255 :param end_date: 结束日期256 :return: 统计数据列表257 """258 res = self._post(259 'getupstreammsgmonth',260 data={261 'begin_date': self._to_date_str(begin_date),262 'end_date': self._to_date_str(end_date)263 },264 result_processor=lambda x: x['list']265 )266 return res267 def get_upstream_msg_dist(self, begin_date, end_date):268 """269 获取消息发送分布数据270 详情请参考271 http://mp.weixin.qq.com/wiki/12/32d42ad542f2e4fc8a8aa60e1bce9838.html272 :param begin_date: 起始日期273 :param end_date: 结束日期274 :return: 统计数据列表275 """276 res = self._post(277 'getupstreammsgdist',278 data={279 'begin_date': self._to_date_str(begin_date),280 'end_date': self._to_date_str(end_date)281 },282 result_processor=lambda x: x['list']283 )284 return res285 def get_upstream_msg_dist_week(self, begin_date, end_date):286 """287 获取消息发送分布数据288 详情请参考289 http://mp.weixin.qq.com/wiki/12/32d42ad542f2e4fc8a8aa60e1bce9838.html290 :param begin_date: 起始日期291 :param end_date: 结束日期292 :return: 统计数据列表293 """294 res = self._post(295 'getupstreammsgdistweek',296 data={297 'begin_date': self._to_date_str(begin_date),298 'end_date': self._to_date_str(end_date)299 },300 result_processor=lambda x: x['list']301 )302 return res303 def get_upstream_msg_dist_month(self, begin_date, end_date):304 """305 获取消息发送分布数据306 详情请参考307 http://mp.weixin.qq.com/wiki/12/32d42ad542f2e4fc8a8aa60e1bce9838.html308 :param begin_date: 起始日期309 :param end_date: 结束日期310 :return: 统计数据列表311 """312 res = self._post(313 'getupstreammsgdistmonth',314 data={315 'begin_date': self._to_date_str(begin_date),316 'end_date': self._to_date_str(end_date)317 },318 result_processor=lambda x: x['list']319 )...

Full Screen

Full Screen

calendar.js

Source:calendar.js Github

copy

Full Screen

1Date.prototype.addDays = function(value) {2 this.setDate(this.getDate() + value);3 return this;4};5Date.prototype.addMonths = function(value) {6 var date = this.getDate();7 this.setMonth(this.getMonth() + value);8 if (this.getDate() < date) {9 this.setDate(0);10 }11 return this;12};13Date.prototype.addWeeks = function(value) {14 this.addDays(value * 7);15 return this;16};17Date.prototype.addYears = function(value) {18 var month = this.getMonth();19 this.setFullYear(this.getFullYear() + value);20 if (month < this.getMonth()) {21 this.setDate(0);22 }23 return this;24};25Date.parseDate = function(date, format) {26 if (format === undefined)27 format = 'Y-m-d';28 var formatSeparator = format.match(/[.\/\-\s].*?/);29 var formatParts = format.split(/\W+/);30 var parts = date.split(formatSeparator);31 var date = new Date();32 if (parts.length === formatParts.length) {33 date.setHours(0);34 date.setMinutes(0);35 date.setSeconds(0);36 date.setMilliseconds(0);37 for (var i=0; i<=formatParts.length; i++) {38 switch(formatParts[i]) {39 case 'dd':40 case 'd':41 case 'j':42 date.setDate(parseInt(parts[i], 10)||1);43 break;44 case 'mm':45 case 'm':46 date.setMonth((parseInt(parts[i], 10)||1) - 1);47 break;48 case 'yy':49 case 'y':50 date.setFullYear(2000 + (parseInt(parts[i], 10)||1));51 break;52 case 'yyyy':53 case 'Y':54 date.setFullYear(parseInt(parts[i], 10)||1);55 break;56 }57 }58 }59 return date;60};61Date.prototype.subDays = function(value) {62 this.setDate(this.getDate() - value);63 return this;64};65Date.prototype.subMonths = function(value) {66 var date = this.getDate();67 this.setMonth(this.getMonth() - value);68 if (this.getDate() < date) {69 this.setDate(0);70 }71 return this;72};73Date.prototype.subWeeks = function(value) {74 this.subDays(value * 7);75 return this;76};77Date.prototype.subYears = function(value) {78 var month = this.getMonth();79 this.setFullYear(this.getFullYear() - value);80 if (month < this.getMonth()) {81 this.setDate(0);82 }83 return this;84};85Date.prototype.format = function(format) {86 if (format === undefined)87 return this.toString();88 var formatSeparator = format.match(/[.\/\-\s].*?/);89 var formatParts = format.split(/\W+/);90 var result = '';91 for (var i=0; i<=formatParts.length; i++) {92 switch(formatParts[i]) {93 case 'd':94 case 'j':95 result += this.getDate() + formatSeparator;96 break;97 case 'dd':98 result += (this.getDate() < 10 ? '0' : '')+this.getDate() + formatSeparator;99 break;100 case 'm':101 result += (this.getMonth() + 1) + formatSeparator;102 break;103 case 'mm':104 result += (this.getMonth() < 9 ? '0' : '')+(this.getMonth() + 1) + formatSeparator;105 break;106 case 'yy':107 case 'y':108 result += this.getFullYear() + formatSeparator;109 break;110 case 'yyyy':111 case 'Y':112 result += this.getFullYear() + formatSeparator;113 break;114 }115 }116 return result.slice(0, -1);117}118function updatePickerFromInput() {119 datepickerStart.setStart($("#date-start").val());120 datepickerStart.setEnd($("#date-end").val());121 datepickerStart.update();122 datepickerEnd.setStart($("#date-start").val());123 datepickerEnd.setEnd($("#date-end").val());124 datepickerEnd.update();125 $('#date-start').trigger('change');126 if ($('#datepicker-compare').attr("checked")) {127 if ($('#compare-options').val() == 1)128 setPreviousPeriod();129 if ($('#compare-options').val() == 2)130 setPreviousYear();131 datepickerStart.setStartCompare($("#date-start-compare").val());132 datepickerStart.setEndCompare($("#date-end-compare").val());133 datepickerEnd.setStartCompare($("#date-start-compare").val());134 datepickerEnd.setEndCompare($("#date-end-compare").val());135 datepickerStart.setCompare(true);136 datepickerEnd.setCompare(true);137 }138}139function setDayPeriod() {140 date = new Date();141 $("#date-start").val(date.format($("#date-start").data('date-format')));142 $("#date-end").val(date.format($("#date-end").data('date-format')));143 $('#date-start').trigger('change');144 updatePickerFromInput();145 $('#datepicker-from-info').html($("#date-start").val());146 $('#datepicker-to-info').html($("#date-end").val());147 $('#preselectDateRange').val('day');148 $('button[name="submitDateRange"]').click();149}150function setPreviousDayPeriod() {151 date = new Date();152 date = date.subDays(1);153 $("#date-start").val(date.format($("#date-start").data('date-format')));154 $("#date-end").val(date.format($("#date-end").data('date-format')));155 $('#date-start').trigger('change');156 updatePickerFromInput();157 $('#datepicker-from-info').html($("#date-start").val());158 $('#datepicker-to-info').html($("#date-end").val());159 $('#preselectDateRange').val('prev-day');160 $('button[name="submitDateRange"]').click();161}162function setMonthPeriod() {163 date = new Date();164 $("#date-end").val(date.format($("#date-end").data('date-format')));165 date = new Date(date.setDate(1));166 $("#date-start").val(date.format($("#date-start").data('date-format')));167 $('#date-start').trigger('change'); 168 updatePickerFromInput();169 $('#datepicker-from-info').html($("#date-start").val());170 $('#datepicker-to-info').html($("#date-end").val());171 $('#preselectDateRange').val('month');172 $('button[name="submitDateRange"]').click();173}174function setPreviousMonthPeriod() {175 date = new Date();176 date = new Date(date.getFullYear(), date.getMonth(), 0);177 $("#date-end").val(date.format($("#date-end").data('date-format')));178 date = new Date(date.setDate(1));179 $("#date-start").val(date.format($("#date-start").data('date-format')));180 $('#date-start').trigger('change'); 181 updatePickerFromInput();182 $('#datepicker-from-info').html($("#date-start").val());183 $('#datepicker-to-info').html($("#date-end").val());184 $('#preselectDateRange').val('prev-month');185 $('button[name="submitDateRange"]').click();186}187function setYearPeriod() {188 date = new Date();189 $("#date-end").val(date.format($("#date-end").data('date-format')));190 date = new Date(date.getFullYear(), 0, 1);191 $("#date-start").val(date.format($("#date-start").data('date-format'))); 192 $('#date-start').trigger('change');193 updatePickerFromInput();194 $('#datepicker-from-info').html($("#date-start").val());195 $('#datepicker-to-info').html($("#date-end").val());196 $('#preselectDateRange').val('year');197 $('button[name="submitDateRange"]').click();198}199function setPreviousYearPeriod() {200 date = new Date();201 date = new Date(date.getFullYear(), 11, 31);202 date = date.subYears(1);203 $("#date-end").val(date.format($("#date-end").data('date-format')));204 date = new Date(date.getFullYear(), 0, 1);205 $("#date-start").val(date.format($("#date-start").data('date-format')));206 $('#date-start').trigger('change');207 updatePickerFromInput();208 $('#datepicker-from-info').html($("#date-start").val());209 $('#datepicker-to-info').html($("#date-end").val());210 $('#preselectDateRange').val('prev-year');211 $('button[name="submitDateRange"]').click();212}213function setPreviousPeriod() {214 startDate = Date.parseDate($("#date-start").val(), $("#date-start").data('date-format')).subDays(1);215 endDate = Date.parseDate($("#date-end").val(), $("#date-end").data('date-format')).subDays(1);216 diff = endDate - startDate;217 startDateCompare = new Date(startDate-diff);218 $("#date-end-compare").val(startDate.format($("#date-end-compare").data('date-format')));219 $("#date-start-compare").val(startDateCompare.format($("#date-start-compare").data('date-format')));220}221function setPreviousYear() {222 startDate = Date.parseDate($("#date-start").val(), $("#date-start").data('date-format')).subYears(1);223 endDate = Date.parseDate($("#date-end").val(), $("#date-end").data('date-format')).subYears(1);224 $("#date-start-compare").val(startDate.format($("#date-start").data('date-format')));225 $("#date-end-compare").val(endDate.format($("#date-start").data('date-format')));226}227$( document ).ready(function() {228 //Instanciate datepickers229 datepickerStart = $('.datepicker1').daterangepicker({230 "dates": translated_dates,231 "weekStart": 1,232 "start": $("#date-start").val(),233 "end": $("#date-end").val()234 }).on('changeDate', function(ev){235 if (ev.date.valueOf() >= datepickerEnd.date.valueOf()){236 datepickerEnd.setValue(ev.date.setMonth(ev.date.getMonth()+1));237 }238 }).data('daterangepicker');239 datepickerEnd = $('.datepicker2').daterangepicker({240 "dates": translated_dates,241 "weekStart": 1,242 "start": $("#date-start").val(),243 "end": $("#date-end").val()244 }).on('changeDate', function(ev){245 if (ev.date.valueOf() <= datepickerStart.date.valueOf()){246 datepickerStart.setValue(ev.date.setMonth(ev.date.getMonth()-1));247 }248 }).data('daterangepicker');249 //Set first date picker to month -1 if same month250 startDate = Date.parseDate($("#date-start").val(), $("#date-start").data('date-format'));251 endDate = Date.parseDate($("#date-end").val(), $("#date-end").data('date-format'));252 if (startDate.getFullYear() == endDate.getFullYear() && startDate.getMonth() == endDate.getMonth())253 datepickerStart.setValue(startDate.subMonths(1));254 //Events binding255 $("#date-start").focus(function() {256 datepickerStart.setCompare(false);257 datepickerEnd.setCompare(false);258 $(".date-input").removeClass("input-selected");259 $(this).addClass("input-selected");260 });261 $("#date-end").focus(function() {262 datepickerStart.setCompare(false);263 datepickerEnd.setCompare(false);264 $(".date-input").removeClass("input-selected");265 $(this).addClass("input-selected");...

Full Screen

Full Screen

test2.py

Source:test2.py Github

copy

Full Screen

...7import matplotlib.pyplot as plt8import time9import datetime10from tools.city import City11def getJsonFilePathList_flyDate(org="BJS",dst="SHA",flydate="20150227"):12 datapath="G:/flightprice_date/"13 date_str=flydate[0:4]+"-"+flydate[4:6]+"-"+flydate[6:8]14 file_path_list=[]15 file_list=file_search.get_all_file(datapath)16 for file in file_list:17 if (org+"_"+dst+"_"+date_str) in file:18 file_path_list.append(file)19 # print(file)20 return file_path_list21#指定json文件名,仓位,获取该json内价格最低的PriceModel对象22def getLeastPriceModel(file_name, cabin="Y"):23 # datapath="G:/20150206"24 # file_name=datapath+"/BJS_SHA_2015-02-07.json"25 flightDataModel = FlightDataModel()26 priceModel = PriceModel()27 leastprice = 99999928 filename_list = file_name.strip().split("/")29 c_date = filename_list[-2]30 fr_in = open(file_name)31 for line in fr_in.readlines():32 obj = jsonpickle.decode(line)33 if cabin == "Y":34 tempprice = obj.leastpriceY35 priceModel.cabin = "Y"36 elif cabin == "C":37 tempprice = obj.leastpriceC38 priceModel.cabin = "C"39 elif cabin == "F":40 tempprice = obj.leastpriceF41 priceModel.cabin = "F"42 else:43 return 044 if tempprice < leastprice:45 leastprice = tempprice46 flightDataModel = obj47 priceModel.fn = flightDataModel.fn48 priceModel.accode = flightDataModel.accode49 priceModel.org = flightDataModel.org50 priceModel.dst = flightDataModel.dst51 priceModel.departureairportcode = flightDataModel.departureairportcode52 priceModel.arrivingairportcode = flightDataModel.arrivingairportcode53 priceModel.src = flightDataModel.src54 priceModel.flydate = flightDataModel.flydate55 priceModel.cdate = c_date56 priceModel.departuretime = flightDataModel.departuretime57 priceModel.arrivingtime = flightDataModel.arrivingtime58 priceModel.leastprice = leastprice59 priceModel.flytimecode = 060 # print(priceModel.printstr())61 return priceModel62def test2():63 Y,C,F=getLeastFlightModel()64 priceCabinY=PriceModel()65 priceCabinY.cabin="Y"66 cabinC=PriceModel()67 cabinC.cabin="C"68 cabinF=PriceModel()69 cabinF.cabin="F"70 priceCabinY.fn=Y.fn71 priceCabinY.accode=Y.accode72 priceCabinY.org=Y.org73 priceCabinY.dst=Y.dst74 priceCabinY.departureairportcode=Y.departureairportcode75 priceCabinY.arrivingairportcode=Y.arrivingairportcode76 priceCabinY.src=Y.src77 priceCabinY.flydate=Y.flydate78 priceCabinY.cdate=Y.cdate79 priceCabinY.departuretime=Y.departuretime80 priceCabinY.arrivingtime=Y.arrivingtime81 priceCabinY.leastprice=Y.leastpriceY82 priceCabinY.flytimecode=083 cabinC.fn=C.fn84 cabinC.accode=C.accode85 cabinC.org=C.org86 cabinC.dst=C.dst87 cabinC.departureairportcode=C.departureairportcode88 cabinC.arrivingairportcode=C.arrivingairportcode89 cabinC.src=C.src90 cabinC.flydate=C.flydate91 cabinC.cdate=C.cdate92 cabinC.departuretime=C.departuretime93 cabinC.arrivingtime=C.arrivingtime94 cabinC.leastprice=C.leastpriceC95 cabinC.flytimecode=096 97 cabinF.fn=F.fn98 cabinF.accode=F.accode99 cabinF.org=F.org100 cabinF.dst=F.dst101 cabinF.departureairportcode=F.departureairportcode102 cabinF.arrivingairportcode=F.arrivingairportcode103 cabinF.src=F.src104 cabinF.flydate=F.flydate105 cabinF.cdate=F.cdate106 cabinF.departuretime=F.departuretime107 cabinF.arrivingtime=F.arrivingtime108 cabinF.leastprice=F.leastpriceF109 cabinF.flytimecode=0110 print(cabinY.printstr())111 print(cabinC.printstr())112 print(cabinF.printstr())113 return cabinY,cabinC,cabinF114def date_change(str_13):115 date_10 = str_13[0:10]116 date_time = time.localtime(int(date_10))117 date1 = time.strftime("%Y%m%d",date_time)118 # print(date1)119 return date1120def plot_price(priceModelList):121 leastPrice_list=[]122 cdate_list=[]123 flydate_list=[]124 for priceModel in priceModelList:125 c_date=priceModel.cdate126 fly_date=priceModel.flydate127 fly_date_int=datetime.datetime.strptime(fly_date,'%Y-%m-%d')128 # c_date_int=datetime.datetime.strptime(c_date,'%Y-%m-%d')129 flydate_list.append(fly_date_int)130 leastPrice_list.append(priceModel.leastprice)131 # leastpriceF_list.append(cabinF.leastpriceF)132 plt.plot(flydate_list,leastPrice_list,"*-")133 plt.xlabel("datetime")134 plt.ylabel("price")135 plt.show()136 pass137def plot_price_flydate(priceModelList):138 leastPrice_list = []139 cDate_list = []140 flyDate_list = []141 dateDifferList = []142 for priceModel in priceModelList:143 c_date = priceModel.cdate144 # print(c_date)145 fly_date = priceModel.flydate146 flyDate_date = datetime.datetime.strptime(fly_date,'%Y-%m-%d')147 cDate_date = datetime.datetime.strptime(c_date,'%Y%m%d')148 # fly_date_int=datetime.datetime.strptime(fly_date,'%Y-%m-%d')149 dateDiffer = (cDate_date - flyDate_date).days150 flyDate_list.append(flyDate_date)151 cDate_list.append(cDate_date)152 leastPrice_list.append(priceModel.leastprice)153 dateDifferList.append(dateDiffer)154 # leastpriceF_list.append(cabinF.leastpriceF)155 print(cDate_list, leastPrice_list)156 print(dateDifferList, leastPrice_list)157 # print(dateDifferList,leastPrice_list)158 # plt.plot(cDate_list,leastPrice_list,"*-")159 plt.plot(dateDifferList, leastPrice_list, "*-")160 plt.xlabel("datetime")161 plt.ylabel("price")162 plt.show()163def plot_main_test(org,dst,cdate="20150209",cabin="Y"):164 if len(org)>3:165 org=City().getCityCode(org)166 dst=City().getCityCode(dst)167 filePathList=getJsonFilePathList(org,dst,cdate)168 # filePathList=getJsonFilePathList(org="BJS",dst="WUH",cdate="20150207")169 # print(filePathList)170 priceModelList=[]171 for filePath in filePathList:172 # print(filePath)173 priceModel=getLeastPriceModel(filePath,cabin=cabin)174 priceModelList.append(priceModel)175 # print(priceModel.printstr())176 plot_price(priceModelList)177 pass178def plot_main_test2(org,dst,flydate="20150227",cabin="Y"):179 if len(org)>3:180 org = City().getCityCode(org)181 dst = City().getCityCode(dst)182 filePathList = getJsonFilePathList_flyDate(org,dst,flydate)183 priceModelList = []184 for filePath in filePathList:185 # print(filePath)186 priceModel = getLeastPriceModel(filePath,cabin=cabin)187 priceModelList.append(priceModel)188 # print(priceModel.printstr())189 # plot_price(priceModelList)190 plot_price_flydate(priceModelList)191 pass192def getLeastPriceModelList(org, dst, flydate, cabin="Y"):193 if len(org)>3:194 org = City().getCityCode(org)195 dst = City().getCityCode(dst)196 filePathList = getJsonFilePathList_flyDate(org,dst,flydate)197 priceModelList = []198 for filePath in filePathList:199 priceModel = getLeastPriceModel(filePath,cabin=cabin)200 priceModelList.append(priceModel)201 return priceModelList202def getLeastDay(org,dst,flydate,cabin="Y"):203 priceModelList = getLeastPriceModelList(org, dst, flydate, cabin)204 #205 # leastPrice_list=[]206 # cDate_list=[]207 # flyDate_list=[]208 # dateDifferList=[]209 leastPrice_temp = 999999210 leastPriceDate_temp = ""211 dateDiffer_temp = ""212 for priceModel in priceModelList:213 leastPrice = priceModel.leastprice214 c_date = priceModel.cdate215 fly_date = priceModel.flydate216 flyDate_date = datetime.datetime.strptime(fly_date,'%Y-%m-%d')217 cDate_date = datetime.datetime.strptime(c_date,'%Y%m%d')218 dateDiffer = (cDate_date - flyDate_date).days219 if leastPrice <= leastPrice_temp:220 leastPrice_temp = leastPrice221 leastPriceDate_temp = c_date222 dateDiffer_temp = dateDiffer223 return leastPrice_temp, leastPriceDate_temp, dateDiffer_temp224 #225 # c_date=priceModel.cdate226 # # print(c_date)227 # fly_date=priceModel.flydate228 # flyDate_date=datetime.datetime.strptime(fly_date,'%Y-%m-%d')229 # cDate_date=datetime.datetime.strptime(c_date,'%Y%m%d')230 # # fly_date_int=datetime.datetime.strptime(fly_date,'%Y-%m-%d')231 #232 # dateDiffer=(cDate_date-flyDate_date).days233 #234 #235 # flyDate_list.append(flyDate_date)236 # cDate_list.append(cDate_date)237 # leastPrice_list.append(priceModel.leastprice)238 #239 # dateDifferList.append(dateDiffer)240 #241 # # leastpriceF_list.append(cabinF.leastpriceF)242 # print(cDate_list,leastPrice_list)243 # print(dateDifferList,leastPrice_list)244if __name__ == "__main__":245 # plot_main_test("广州","武汉",cdate="20150210",cabin="Y")246 # plot_main_test2("广州","武汉",flydate="20150227",cabin="Y")247 # getJsonFilePathList_flyDate()248 # plot_main_test2("北京","上海",flydate="20150228",cabin="F")249 # plot_main_test2("广州","武汉",flydate="20150304",cabin="Y")250 # A,B,C=getLeastDay("广州","武汉",flydate="20150304",cabin="Y")251 # print(A,B,C)252 base_date = "20150210"253 date_str = datetime.datetime.strptime(base_date,'%Y%m%d')254 leastPrice_list = []255 dateString_list = []256 dateDiffer_list = []257 for i in range(20):258 date_str_temp = date_str + datetime.timedelta(days=i)259 # dateString=time.strftime("%Y%m%d", date_str_temp)260 dateString = date_str_temp.strftime("%Y%m%d")261 leastPrice, leastPriceDate, dateDiffer = getLeastDay("北京", "上海", flydate=dateString, cabin="Y")...

Full Screen

Full Screen

Date.js

Source:Date.js Github

copy

Full Screen

...27 },28 {29 name: "toGregorian",30 runTest: function(t){31 var dateBuddhist = new dojox.date.buddhist.Date(2551, 11, 19); //Buddhist.Date month 0-1232 var dateGregorian = dateBuddhist.toGregorian();33 t.is(0, dojo.date.compare(new Date(2008, 11, 19), dateGregorian, "date"));//Date month 0-1134 35 dateBuddhist = new dojox.date.buddhist.Date(2548, 3, 18);36 dateGregorian = dateBuddhist.toGregorian();37 t.is(0, dojo.date.compare(new Date(2005, 3, 18), dateGregorian, "date"));38 39 dateBuddhist = new dojox.date.buddhist.Date(2550, 7, 10);40 dateGregorian = dateBuddhist.toGregorian();41 t.is(0, dojo.date.compare(new Date(2007, 7, 10), dateGregorian, "date"));42 43 dateBuddhist = new dojox.date.buddhist.Date(2552, 4, 20);44 dateGregorian = dateBuddhist.toGregorian();45 t.is(0, dojo.date.compare(new Date(2009, 4, 20), dateGregorian, "date"));46 47 dateBuddhist = new dojox.date.buddhist.Date(2553, 6, 31);48 dateGregorian = dateBuddhist.toGregorian();49 t.is(0, dojo.date.compare(new Date(2010, 6, 31), dateGregorian, "date"));50 51 dateBuddhist = new dojox.date.buddhist.Date(2554, 9, 1);52 dateGregorian = dateBuddhist.toGregorian();53 t.is(0, dojo.date.compare(new Date(2011, 9, 1), dateGregorian, "date"));54 }55 },56 {57 name: "fromGregorian",58 runTest: function(t){59 var dateGregorian = new Date(2009, 3, 12);60 var dateBuddhistFromGreg = new dojox.date.buddhist.Date(dateGregorian);61 t.is(0, dojo.date.compare( dateBuddhistFromGreg.toGregorian(), dateGregorian, "date"));62 t.is(0, dojo.date.compare( dateBuddhistFromGreg.toGregorian(), dateGregorian));63 64 dateGregorian = new Date(2008, 11, 18); //Date month 0-1165 dateBuddhistFromGreg = new dojox.date.buddhist.Date(dateGregorian);66 t.is(0, dojox.date.buddhist.compare(new dojox.date.buddhist.Date(2551, 11, 18), dateBuddhistFromGreg, "date")); //Buddhist.Date month 0-1267 68 dateGregorian = new Date(2005, 3, 18);69 dateBuddhistFromGreg = new dojox.date.buddhist.Date(dateGregorian);70 t.is(0, dojox.date.buddhist.compare(new dojox.date.buddhist.Date(2548, 3, 18), dateBuddhistFromGreg, "date"));71 72 dateGregorian = new Date(2007, 7, 10);73 dateBuddhistFromGreg = new dojox.date.buddhist.Date(dateGregorian);74 t.is(0, dojox.date.buddhist.compare(new dojox.date.buddhist.Date(2550, 7, 10), dateBuddhistFromGreg, "date"));75 76 dateGregorian = new Date(2009, 4, 20);77 dateBuddhistFromGreg = new dojox.date.buddhist.Date(dateGregorian);78 t.is(0, dojox.date.buddhist.compare(new dojox.date.buddhist.Date(2552, 4, 20), dateBuddhistFromGreg, "date"));79 80 dateGregorian = new Date(2010, 6, 31);81 dateBuddhistFromGreg = new dojox.date.buddhist.Date(dateGregorian);82 t.is(0, dojox.date.buddhist.compare(new dojox.date.buddhist.Date(2553, 6, 31), dateBuddhistFromGreg, "date"));83 84 dateGregorian = new Date(2011, 9, 1);85 dateBuddhistFromGreg = new dojox.date.buddhist.Date(dateGregorian);86 t.is(0, dojox.date.buddhist.compare(new dojox.date.buddhist.Date(2554, 9, 1), dateBuddhistFromGreg, "date"));87 }88 },89 {90 name: "compare",91 runTest: function(t){92 var dateBuddhist = new dojox.date.buddhist.Date(2552, 5, 16);93 var dateBuddhist1 = new dojox.date.buddhist.Date(2550, 10, 25);94 t.is(1, dojo.date.compare(dateBuddhist.toGregorian(), dateBuddhist1.toGregorian()));95 t.is(-1, dojo.date.compare(dateBuddhist1.toGregorian(), dateBuddhist.toGregorian()));96 }97 },98 {99 name: "add_and_difference",100 runTest: function(t){101 var dateBuddhist = new dojox.date.buddhist.Date(2552, 5, 16);102 var dateBuddhistLeap = new dojox.date.buddhist.Date(2551, 5, 16);103 104 var dateBuddhistAdd = dojox.date.buddhist.add(dateBuddhist, "month", 18);105 var dateBuddhistAddLeap = dojox.date.buddhist.add(dateBuddhistLeap, "month", 18);106 t.is(0, 18 - dojox.date.buddhist.difference(dateBuddhistAdd, dateBuddhist, "month"));107 t.is(0, 18 - dojox.date.buddhist.difference(dateBuddhistAddLeap, dateBuddhistLeap, "month"));108 109 var dateBuddhistAdd1= dojox.date.buddhist.add(dateBuddhist, "year", 2);110 t.is(0, 2 - dojox.date.buddhist.difference(dateBuddhistAdd1, dateBuddhist, "year"));111 t.is(0, 2 - dojox.date.buddhist.difference(dojox.date.buddhist.add(dateBuddhistLeap, "year", 2), dateBuddhistLeap, "year"));112 113 var dateBuddhistAdd2= dojox.date.buddhist.add(dateBuddhist, "week", 12);114 t.is(0, 12 - dojox.date.buddhist.difference(dateBuddhistAdd2, dateBuddhist, "week"));115 t.is(0, 12 - dojox.date.buddhist.difference(dojox.date.buddhist.add(dateBuddhistLeap, "week", 12), dateBuddhistLeap,"week"));116 117 var dateBuddhistAdd3= dojox.date.buddhist.add(dateBuddhist, "weekday", 20);118 t.is(0, 20 - dojox.date.buddhist.difference(dateBuddhistAdd3, dateBuddhist, "weekday"));119 t.is(0, 20 - dojox.date.buddhist.difference(dojox.date.buddhist.add(dateBuddhistLeap, "weekday", 20), dateBuddhistLeap,"weekday"));120 121 var dateBuddhistAdd4= dojox.date.buddhist.add(dateBuddhist, "day", -50)122 t.is(0, -50 - dojox.date.buddhist.difference(dateBuddhistAdd4, dateBuddhist, "day"));123 t.is(0, -50 - dojox.date.buddhist.difference(dojox.date.buddhist.add(dateBuddhistLeap, "day", -50), dateBuddhistLeap,"day"));124 125 var dateBuddhistAdd5= dojox.date.buddhist.add(dateBuddhist, "hour", 200);126 t.is(0, 200 - dojox.date.buddhist.difference(dateBuddhistAdd5, dateBuddhist, "hour"));127 t.is(0, 200 - dojox.date.buddhist.difference(dojox.date.buddhist.add(dateBuddhistLeap, "hour", 200), dateBuddhistLeap,"hour"));128 129 var dateBuddhistAdd6= dojox.date.buddhist.add(dateBuddhist, "minute", -200);130 t.is(0, -200 - dojox.date.buddhist.difference(dateBuddhistAdd6, dateBuddhist, "minute"));131 t.is(0, -200 - dojox.date.buddhist.difference(dojox.date.buddhist.add(dateBuddhistLeap, "minute", -200), dateBuddhistLeap,"minute"));132 133 var dateBuddhistDiff = new dojox.date.buddhist.Date(2552, 5, 17);134 t.is(1, dojox.date.buddhist.difference(dateBuddhistDiff, dateBuddhist));135 }136 },137 {138 name: "parse_and_format",139 runTest: function(t){140 var dateBuddhist = new dojox.date.buddhist.Date(2552, 5, 16);141 142 var options = {formatLength:'short'};143 str= dojox.date.buddhist.locale.format(dateBuddhist, options);144 dateBuddhist1 = dojox.date.buddhist.locale.parse(str, options);145 t.is(0, dojo.date.compare(dateBuddhist.toGregorian(), dateBuddhist1.toGregorian(), 'date'));146 147 var pat = 'dd/MM/yy h:m:s';148 options = {datePattern:pat, selector:'date'};149 str= dojox.date.buddhist.locale.format(dateBuddhist, options);150 dateBuddhist1 = dojox.date.buddhist.locale.parse(str, options);151 t.is(0, dojo.date.compare(dateBuddhist.toGregorian(), dateBuddhist1.toGregorian(), 'date'));152 153 pat = 'dd#MM#yy HH$mm$ss';154 options = {datePattern:pat, selector:'date'};...

Full Screen

Full Screen

dateutil.py

Source:dateutil.py Github

copy

Full Screen

1#encoding=utf-82import datetime3import time4class DateUtil:5 @staticmethod6 def getToday():7 now_time = datetime.datetime.now()8 # yes_time = now_time + datetime.timedelta(days=-1)9 return now_time.strftime('%Y%m%d')10 # return time.strftime('%Y-%m-%d',time.localtime(tim.e.time()))11 @staticmethod12 def getYestaday():13 now_time = datetime.datetime.now()14 yes_time = now_time + datetime.timedelta(days=-1)15 return yes_time.strftime('%Y%m%d')16 # return time.strftime('%Y-%m-%d',time.localtime(time.time()))17 @staticmethod18 def str2str(date_str, fmt_src, fmt_dst):19 date = datetime.datetime.strptime(date_str, fmt_src)20 return date.strftime(fmt_dst)21 ''' get the last time in seconds of the date in fmt_src '''22 @staticmethod23 def getlast_insecond(date_str_src, fmt_src):24 date_str_dest = DateUtil.str2str(date_str_src, fmt_src, '%Y-%m-%d')25 return date_str_dest + " 23:59:59"26 @staticmethod27 def getfirst_insecond(date_str_src, fmt_src):28 date_str_dest = DateUtil.str2str(date_str_src, fmt_src, '%Y-%m-%d')29 return date_str_dest + " 00:00:00"30 @staticmethod31 def get_date(year, month, day):32 date = datetime.datetime(year, month, day)33 @staticmethod34 def get_date_str(year, month, day):35 date = datetime.datetime(year, month, day)36 return DateUtil.date2str(date, '%Y-%m-%d')37 @staticmethod38 def is_leap(year):39 if year%4 != 0:40 return False41 else:42 if year%100 == 0 and year%400 != 0:43 return False44 else:45 return True46 @staticmethod47 def get_daysofmonth(year, month):48 if month in [1, 3, 5, 7, 8, 10, 12]:49 return 3150 elif month in [4, 6, 9, 11]:51 return 3052 else:53 if DateUtil.is_leap(year):54 return 2955 else:56 return 2857 @staticmethod58 def is_weekend(date_str, fmt='%Y-%m-%d'):59 date = DateUtil.str2date(date_str, fmt)60 return DateUtil.is_weekend2(date)61 @staticmethod62 def is_weekend2(date):63 dayofweek = date.isoweekday()64 if dayofweek in [6, 7]:65 return True66 else:67 return False68 @staticmethod69 def get_weekendsofmonth(year, month):70 days = DateUtil.get_daysofmonth(year, month)71 weekends = []72 for i in range(days):73 tmp_date = datetime.datetime(year, month, i+1)74 if DateUtil.is_weekend2(tmp_date):75 weekends.append(DateUtil.date2str(tmp_date, '%Y-%m-%d'))76 return weekends77 @staticmethod78 def get_worktimeofday(date):79 plus1 = datetime.timedelta(hours=8)80 plus2 = datetime.timedelta(hours=18)81 date_start = date+plus182 date_end = date+plus283 return DateUtil.date2str(date_start), DateUtil.date2str(date_end)84 @staticmethod85 def get_weektimeofmonth(year, month):86 days = DateUtil.get_daysofmonth(year, month)87 weekdays_start = []88 weekdays_end = []89 for i in range(days):90 tmp_date = datetime.datetime(year, month, i+1)91 if not DateUtil.is_weekend2(tmp_date):92 tmp_start, tmp_end = DateUtil.get_worktimeofday(tmp_date)93 weekdays_start.append(tmp_start)94 weekdays_end.append(tmp_end)95 return weekdays_start, weekdays_end96 @staticmethod97 def date2str(date, fmt_dst='%Y-%m-%d %H:%M:%S'):98 if not date:99 return None100 return date.strftime(fmt_dst)101 @staticmethod102 def str2date(date_str, fmt_dst='%Y-%m-%d %H:%M:%S'):103 return datetime.datetime.strptime(date_str, fmt_dst)104 @staticmethod105 def minus_days(date_str1, date_str2, fmt='%Y-%m-%d'):106 minus = DateUtil.str2date(date_str2, fmt)-DateUtil.str2date(date_str1, fmt)107 return minus.days108 @staticmethod109 def minus_insecond(date_str1, date_str2, fmt='%Y-%m-%d %H:%M:%S'):110 minus = DateUtil.str2date(date_str2, fmt) - DateUtil.str2date(date_str1, fmt)111 return minus.seconds112 @staticmethod113 def plus_hours(date_str, num, fmt='%Y-%m-%d %H:%M:%S'):114 date_dst = DateUtil.str2date(date_str, '%Y-%m-%d')+datetime.timedelta(hours=num)115 return DateUtil.date2str(date_dst, fmt)116 @staticmethod117 def minus_seconds(date, num, fmt='%Y-%m-%d %H:%M:%S'):118 date_dst = date-datetime.timedelta(seconds=num)119 return DateUtil.date2str(date_dst, fmt)120 @staticmethod121 def minus_minutes(date_str, num, fmt='%Y-%m-%d %H:%M:%S'):122 date = DateUtil.str2date(date_str)123 date_dst = date-datetime.timedelta(minutes=num)124 return DateUtil.date2str(date_dst, fmt)125 @staticmethod126 def plus_minutes(date_str, num, fmt='%Y-%m-%d %H:%M:%S'):127 return DateUtil.minus_minutes(date_str, -num, fmt)128 @staticmethod129 def now_date():130 return datetime.datetime.now()131 @staticmethod132 def yeaterday_str(fmt='%Y-%m-%d'):133 yesterday = DateUtil.now_date() - datetime.timedelta(days=1)134 return DateUtil.date2str(yesterday, fmt)135 @staticmethod136 def plus_days(date_str1, num, fmt='%Y-%m-%d'):137 date_dst = DateUtil.str2date(date_str1, fmt)+datetime.timedelta(days=num)138 return DateUtil.date2str(date_dst, fmt)139 @staticmethod140 def from_to(date_str_from, date_str_to, fmt='%Y-%m-%d'):141 days = DateUtil.minus_days(date_str_from, date_str_to, fmt)142 for i in range(days):143 yield DateUtil.plus_days(date_str_from, i, fmt)144 #@staticmethod145 #def get_worktime(year, month):146def test():147 #print DateUtil.str2str('2013-04-12', '%Y-%m-%d', '%Y-%m-%d %H:%M:%S')148 #print DateUtil.getlast_insecond('2013-04-12', '%Y-%m-%d')149 #print DateUtil.getfirst_insecond('2013-04-12 12:12:12', '%Y-%m-%d %H:%M:%S')150 #print DateUtil.minus_days('2013-04-13', '2013-04-15')151 #print DateUtil.plus_days('2013-05-09', 9)152 #print DateUtil.plus_hours('2013-05-10', 4)153 #print DateUtil.minus_seconds('2013-04-12 12:12:12', 10)154 #print DateUtil.minus_insecond('2013-04-12 12:12:12', '2013-04-12 12:12:13')155 print DateUtil.get_daysofmonth(2013, 12)156 print DateUtil.is_weekend('2013-10-21')157 print DateUtil.get_weektimeofmonth(2013, 10)158 print DateUtil.get_date_str(2013, 10, 9)159 print DateUtil.yeaterday_str()160if __name__ == '__main__':...

Full Screen

Full Screen

other.ts

Source:other.ts Github

copy

Full Screen

...7 fullMonth: 'dd MMMM yyyy',8 };9 static today = (): DateFormat => {10 const dateFormat = new DateFormat();11 dateFormat.date = new Date();12 return dateFormat;13 };14 static fromISO = (iso: string): DateFormat => {15 const dateFormat = new DateFormat();16 dateFormat.fromISO(iso);17 return dateFormat;18 };19 static fromDate = (date: Date): DateFormat => {20 const dateFormat = new DateFormat();21 dateFormat.fromDate(date);22 return dateFormat;23 };24 static min = (dateFormats: Array<DateFormat | undefined>): DateFormat | undefined => {25 let min: DateFormat | undefined;26 dateFormats.forEach(dateFormat => {27 if (dateFormat?.date === undefined) return;28 if (min === undefined || (min.date !== undefined && dateFormat.date < min.date))29 min = dateFormat;30 });31 return min;32 };33 static max = (dateFormats: Array<DateFormat | undefined>): DateFormat | undefined => {34 let max: DateFormat | undefined;35 dateFormats.forEach(dateFormat => {...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var d = new Date();2console.log(d);3var d2 = new child.Date();4console.log(d2);5Thu Jan 19 2017 19:38:01 GMT+0530 (India Standard Time)6Thu Jan 19 2017 19:38:01 GMT+0530 (India Standard Time)7var d = new Date();8console.log(d);9child.Date = function() {10 return "Overridden Date Method";11}12var d2 = new child.Date();13console.log(d2);14Thu Jan 19 2017 19:38:01 GMT+0530 (India Standard Time)15var d = new Date();16console.log(d);17child.Date.prototype = function() {18 return "Overridden Date Method";19}20var d2 = new child.Date();21console.log(d2);22Thu Jan 19 2017 19:38:01 GMT+0530 (India Standard

Full Screen

Using AI Code Generation

copy

Full Screen

1root.Date();2root.Date();3I've tried a few different ways to import the Date method from the root, but none of them seem to work. I just want to be able to use the Date method in the test.js file. Is there a way to do this?4function test1() {5 console.log("test1");6}7var file1 = require("./file1.js");8file1.test1();9var fs = require('fs');10var text = "Hello World!";11fs.writeFile('test.txt', text, function(err) {12 if (err) throw err;13 console.log('Saved!');14});15var fs = require('fs');16fs.readFile('test.txt', function(err, data) {17 if (err) throw err;18 console.log(data);19});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful