Best JavaScript code snippet using wpt
funcs.js
Source:funcs.js
1import axios from "axios";2//generate date now3export const getTodayDate = (dateNow) =>4 `${dateNow.getMonth() + 1}.${dateNow.getDate()}.${dateNow.getFullYear()}`;5//generate dates for two weeks6export const getTwoWeeks = (dateNow) => {7 let mondayThisWeek,8 tuesdayThisWeek,9 wednesdayThisWeek,10 thursdayThisWeek,11 fridayThisWeek,12 mondayNextWeek,13 tuesdayNextWeek,14 wednesdayNextWeek,15 thursdayNextWeek,16 fridayNextWeek,17 mondayDate,18 tuesdayDate,19 wednesdayDate,20 thursdayDate,21 fridayDate,22 mondayNextDate,23 tuesdayNextDate,24 wednesdayNextDate,25 thursdayNextDate,26 fridayNextDate;27 switch (+dateNow.getDay()) {28 case 0:29 //monday START30 mondayDate = new Date(31 dateNow.getFullYear(),32 dateNow.getMonth(),33 dateNow.getDate() + 134 );35 mondayThisWeek = `${36 mondayDate.getMonth() + 137 }.${mondayDate.getDate()}.${mondayDate.getFullYear()}`;38 //monday FINISH39 //tuesday START40 tuesdayDate = new Date(41 dateNow.getFullYear(),42 dateNow.getMonth(),43 dateNow.getDate() + 244 );45 tuesdayThisWeek = `${46 tuesdayDate.getMonth() + 147 }.${tuesdayDate.getDate()}.${tuesdayDate.getFullYear()}`;48 //tuesday FINISH49 //wednesday START50 wednesdayDate = new Date(51 dateNow.getFullYear(),52 dateNow.getMonth(),53 dateNow.getDate() + 354 );55 wednesdayThisWeek = `${56 wednesdayDate.getMonth() + 157 }.${wednesdayDate.getDate()}.${wednesdayDate.getFullYear()}`;58 //wednesday FINISH59 //thursday START60 thursdayDate = new Date(61 dateNow.getFullYear(),62 dateNow.getMonth(),63 dateNow.getDate() + 464 );65 thursdayThisWeek = `${66 thursdayDate.getMonth() + 167 }.${thursdayDate.getDate()}.${thursdayDate.getFullYear()}`;68 //thursday FINISH69 //friday START70 fridayDate = new Date(71 dateNow.getFullYear(),72 dateNow.getMonth(),73 dateNow.getDate() + 574 );75 fridayThisWeek = `${76 fridayDate.getMonth() + 177 }.${fridayDate.getDate()}.${fridayDate.getFullYear()}`;78 //friday FINISH79 //next monday START80 mondayNextDate = new Date(81 dateNow.getFullYear(),82 dateNow.getMonth(),83 dateNow.getDate() + 884 );85 mondayNextWeek = `${86 mondayNextDate.getMonth() + 187 }.${mondayNextDate.getDate()}.${mondayNextDate.getFullYear()}`;88 //next monday FINISH89 //next tuesday START90 tuesdayNextDate = new Date(91 dateNow.getFullYear(),92 dateNow.getMonth(),93 dateNow.getDate() + 994 );95 tuesdayNextWeek = `${96 tuesdayNextDate.getMonth() + 197 }.${tuesdayNextDate.getDate()}.${tuesdayNextDate.getFullYear()}`;98 //next tuesday FINISH99 //next wednesday START100 wednesdayNextDate = new Date(101 dateNow.getFullYear(),102 dateNow.getMonth(),103 dateNow.getDate() + 10104 );105 wednesdayNextWeek = `${106 wednesdayNextDate.getMonth() + 1107 }.${wednesdayNextDate.getDate()}.${wednesdayNextDate.getFullYear()}`;108 //next wednesday FINISH109 //next thursday START110 thursdayNextDate = new Date(111 dateNow.getFullYear(),112 dateNow.getMonth(),113 dateNow.getDate() + 11114 );115 thursdayNextWeek = `${116 thursdayNextDate.getMonth() + 1117 }.${thursdayNextDate.getDate()}.${thursdayNextDate.getFullYear()}`;118 //next thursday FINISH119 //next friday START120 fridayNextDate = new Date(121 dateNow.getFullYear(),122 dateNow.getMonth(),123 dateNow.getDate() + 12124 );125 fridayNextWeek = `${126 fridayNextDate.getMonth() + 1127 }.${fridayNextDate.getDate()}.${fridayNextDate.getFullYear()}`;128 //next friday FINISH129 break;130 case 1:131 //monday START132 mondayThisWeek = `${133 dateNow.getMonth() + 1134 }.${dateNow.getDate()}.${dateNow.getFullYear()}`;135 //monday FINISH136 //tuesday START137 tuesdayDate = new Date(138 dateNow.getFullYear(),139 dateNow.getMonth(),140 dateNow.getDate() + 1141 );142 tuesdayThisWeek = `${143 tuesdayDate.getMonth() + 1144 }.${tuesdayDate.getDate()}.${tuesdayDate.getFullYear()}`;145 //tuesday FINISH146 //wednesday START147 wednesdayDate = new Date(148 dateNow.getFullYear(),149 dateNow.getMonth(),150 dateNow.getDate() + 2151 );152 wednesdayThisWeek = `${153 wednesdayDate.getMonth() + 1154 }.${wednesdayDate.getDate()}.${wednesdayDate.getFullYear()}`;155 //wednesday FINISH156 //thursday START157 thursdayDate = new Date(158 dateNow.getFullYear(),159 dateNow.getMonth(),160 dateNow.getDate() + 3161 );162 thursdayThisWeek = `${163 thursdayDate.getMonth() + 1164 }.${thursdayDate.getDate()}.${thursdayDate.getFullYear()}`;165 //thursday FINISH166 //friday START167 fridayDate = new Date(168 dateNow.getFullYear(),169 dateNow.getMonth(),170 dateNow.getDate() + 4171 );172 fridayThisWeek = `${173 fridayDate.getMonth() + 1174 }.${fridayDate.getDate()}.${fridayDate.getFullYear()}`;175 //friday FINISH176 //next monday START177 mondayNextDate = new Date(178 dateNow.getFullYear(),179 dateNow.getMonth(),180 dateNow.getDate() + 7181 );182 mondayNextWeek = `${183 mondayNextDate.getMonth() + 1184 }.${mondayNextDate.getDate()}.${mondayNextDate.getFullYear()}`;185 //next monday FINISH186 //next tuesday START187 tuesdayNextDate = new Date(188 dateNow.getFullYear(),189 dateNow.getMonth(),190 dateNow.getDate() + 8191 );192 tuesdayNextWeek = `${193 tuesdayNextDate.getMonth() + 1194 }.${tuesdayNextDate.getDate()}.${tuesdayNextDate.getFullYear()}`;195 //next tuesday FINISH196 //next wednesday START197 wednesdayNextDate = new Date(198 dateNow.getFullYear(),199 dateNow.getMonth(),200 dateNow.getDate() + 9201 );202 wednesdayNextWeek = `${203 wednesdayNextDate.getMonth() + 1204 }.${wednesdayNextDate.getDate()}.${wednesdayNextDate.getFullYear()}`;205 //next wednesday FINISH206 //next thursday START207 thursdayNextDate = new Date(208 dateNow.getFullYear(),209 dateNow.getMonth(),210 dateNow.getDate() + 10211 );212 thursdayNextWeek = `${213 thursdayNextDate.getMonth() + 1214 }.${thursdayNextDate.getDate()}.${thursdayNextDate.getFullYear()}`;215 //next thursday FINISH216 //next friday START217 fridayNextDate = new Date(218 dateNow.getFullYear(),219 dateNow.getMonth(),220 dateNow.getDate() + 11221 );222 fridayNextWeek = `${223 fridayNextDate.getMonth() + 1224 }.${fridayNextDate.getDate()}.${fridayNextDate.getFullYear()}`;225 //next friday FINISH226 break;227 case 2:228 //monday START229 mondayDate = new Date(230 dateNow.getFullYear(),231 dateNow.getMonth(),232 dateNow.getDate() - 1233 );234 mondayThisWeek = `${235 mondayDate.getMonth() + 1236 }.${mondayDate.getDate()}.${mondayDate.getFullYear()}`;237 //monday FINISH238 //tuesday START239 tuesdayThisWeek = `${240 dateNow.getMonth() + 1241 }.${dateNow.getDate()}.${dateNow.getFullYear()}`;242 //tuesday FINISH243 //wednesday START244 wednesdayDate = new Date(245 dateNow.getFullYear(),246 dateNow.getMonth(),247 dateNow.getDate() + 1248 );249 wednesdayThisWeek = `${250 wednesdayDate.getMonth() + 1251 }.${wednesdayDate.getDate()}.${wednesdayDate.getFullYear()}`;252 //wednesday FINISH253 //thursday START254 thursdayDate = new Date(255 dateNow.getFullYear(),256 dateNow.getMonth(),257 dateNow.getDate() + 2258 );259 thursdayThisWeek = `${260 thursdayDate.getMonth() + 1261 }.${thursdayDate.getDate()}.${thursdayDate.getFullYear()}`;262 //thursday FINISH263 //friday START264 fridayDate = new Date(265 dateNow.getFullYear(),266 dateNow.getMonth(),267 dateNow.getDate() + 3268 );269 fridayThisWeek = `${270 fridayDate.getMonth() + 1271 }.${fridayDate.getDate()}.${fridayDate.getFullYear()}`;272 //friday FINISH273 //next monday START274 mondayNextDate = new Date(275 dateNow.getFullYear(),276 dateNow.getMonth(),277 dateNow.getDate() + 6278 );279 mondayNextWeek = `${280 mondayNextDate.getMonth() + 1281 }.${mondayNextDate.getDate()}.${mondayNextDate.getFullYear()}`;282 //next monday FINISH283 //next tuesday START284 tuesdayNextDate = new Date(285 dateNow.getFullYear(),286 dateNow.getMonth(),287 dateNow.getDate() + 7288 );289 tuesdayNextWeek = `${290 tuesdayNextDate.getMonth() + 1291 }.${tuesdayNextDate.getDate()}.${tuesdayNextDate.getFullYear()}`;292 //next tuesday FINISH293 //next wednesday START294 wednesdayNextDate = new Date(295 dateNow.getFullYear(),296 dateNow.getMonth(),297 dateNow.getDate() + 8298 );299 wednesdayNextWeek = `${300 wednesdayNextDate.getMonth() + 1301 }.${wednesdayNextDate.getDate()}.${wednesdayNextDate.getFullYear()}`;302 //next wednesday FINISH303 //next thursday START304 thursdayNextDate = new Date(305 dateNow.getFullYear(),306 dateNow.getMonth(),307 dateNow.getDate() + 9308 );309 thursdayNextWeek = `${310 thursdayNextDate.getMonth() + 1311 }.${thursdayNextDate.getDate()}.${thursdayNextDate.getFullYear()}`;312 //next thursday FINISH313 //next friday START314 fridayNextDate = new Date(315 dateNow.getFullYear(),316 dateNow.getMonth(),317 dateNow.getDate() + 10318 );319 fridayNextWeek = `${320 fridayNextDate.getMonth() + 1321 }.${fridayNextDate.getDate()}.${fridayNextDate.getFullYear()}`;322 //next friday FINISH323 break;324 case 3:325 //monday START326 mondayDate = new Date(327 dateNow.getFullYear(),328 dateNow.getMonth(),329 dateNow.getDate() - 2330 );331 mondayThisWeek = `${332 mondayDate.getMonth() + 1333 }.${mondayDate.getDate()}.${mondayDate.getFullYear()}`;334 //monday FINISH335 //tuesday START336 tuesdayDate = new Date(337 dateNow.getFullYear(),338 dateNow.getMonth(),339 dateNow.getDate() - 1340 );341 tuesdayThisWeek = `${342 tuesdayDate.getMonth() + 1343 }.${tuesdayDate.getDate()}.${tuesdayDate.getFullYear()}`;344 //tuesday FINISH345 //wednesday START346 wednesdayThisWeek = `${347 dateNow.getMonth() + 1348 }.${dateNow.getDate()}.${dateNow.getFullYear()}`;349 //wednesday FINISH350 //thursday START351 thursdayDate = new Date(352 dateNow.getFullYear(),353 dateNow.getMonth(),354 dateNow.getDate() + 1355 );356 thursdayThisWeek = `${357 thursdayDate.getMonth() + 1358 }.${thursdayDate.getDate()}.${thursdayDate.getFullYear()}`;359 //thursday FINISH360 //friday START361 fridayDate = new Date(362 dateNow.getFullYear(),363 dateNow.getMonth(),364 dateNow.getDate() + 2365 );366 fridayThisWeek = `${367 fridayDate.getMonth() + 1368 }.${fridayDate.getDate()}.${fridayDate.getFullYear()}`;369 //friday FINISH370 //next monday START371 mondayNextDate = new Date(372 dateNow.getFullYear(),373 dateNow.getMonth(),374 dateNow.getDate() + 5375 );376 mondayNextWeek = `${377 mondayNextDate.getMonth() + 1378 }.${mondayNextDate.getDate()}.${mondayNextDate.getFullYear()}`;379 //next monday FINISH380 //next tuesday START381 tuesdayNextDate = new Date(382 dateNow.getFullYear(),383 dateNow.getMonth(),384 dateNow.getDate() + 6385 );386 tuesdayNextWeek = `${387 tuesdayNextDate.getMonth() + 1388 }.${tuesdayNextDate.getDate()}.${tuesdayNextDate.getFullYear()}`;389 //next tuesday FINISH390 //next wednesday START391 wednesdayNextDate = new Date(392 dateNow.getFullYear(),393 dateNow.getMonth(),394 dateNow.getDate() + 7395 );396 wednesdayNextWeek = `${397 wednesdayNextDate.getMonth() + 1398 }.${wednesdayNextDate.getDate()}.${wednesdayNextDate.getFullYear()}`;399 //next wednesday FINISH400 //next thursday START401 thursdayNextDate = new Date(402 dateNow.getFullYear(),403 dateNow.getMonth(),404 dateNow.getDate() + 8405 );406 thursdayNextWeek = `${407 thursdayNextDate.getMonth() + 1408 }.${thursdayNextDate.getDate()}.${thursdayNextDate.getFullYear()}`;409 //next thursday FINISH410 //next friday START411 fridayNextDate = new Date(412 dateNow.getFullYear(),413 dateNow.getMonth(),414 dateNow.getDate() + 9415 );416 fridayNextWeek = `${417 fridayNextDate.getMonth() + 1418 }.${fridayNextDate.getDate()}.${fridayNextDate.getFullYear()}`;419 //next friday FINISH420 break;421 case 4:422 //monday START423 mondayDate = new Date(424 dateNow.getFullYear(),425 dateNow.getMonth(),426 dateNow.getDate() - 3427 );428 mondayThisWeek = `${429 mondayDate.getMonth() + 1430 }.${mondayDate.getDate()}.${mondayDate.getFullYear()}`;431 //monday FINISH432 //tuesday START433 tuesdayDate = new Date(434 dateNow.getFullYear(),435 dateNow.getMonth(),436 dateNow.getDate() - 2437 );438 tuesdayThisWeek = `${439 tuesdayDate.getMonth() + 1440 }.${tuesdayDate.getDate()}.${tuesdayDate.getFullYear()}`;441 //tuesday FINISH442 //wednesday START443 wednesdayDate = new Date(444 dateNow.getFullYear(),445 dateNow.getMonth(),446 dateNow.getDate() - 1447 );448 wednesdayThisWeek = `${449 wednesdayDate.getMonth() + 1450 }.${wednesdayDate.getDate()}.${wednesdayDate.getFullYear()}`;451 //wednesday FINISH452 //thursday START453 thursdayThisWeek = `${454 dateNow.getMonth() + 1455 }.${dateNow.getDate()}.${dateNow.getFullYear()}`;456 //thursday FINISH457 //friday START458 fridayDate = new Date(459 dateNow.getFullYear(),460 dateNow.getMonth(),461 dateNow.getDate() + 1462 );463 fridayThisWeek = `${464 fridayDate.getMonth() + 1465 }.${fridayDate.getDate()}.${fridayDate.getFullYear()}`;466 //friday FINISH467 //next monday START468 mondayNextDate = new Date(469 dateNow.getFullYear(),470 dateNow.getMonth(),471 dateNow.getDate() + 4472 );473 mondayNextWeek = `${474 mondayNextDate.getMonth() + 1475 }.${mondayNextDate.getDate()}.${mondayNextDate.getFullYear()}`;476 //next monday FINISH477 //next tuesday START478 tuesdayNextDate = new Date(479 dateNow.getFullYear(),480 dateNow.getMonth(),481 dateNow.getDate() + 5482 );483 tuesdayNextWeek = `${484 tuesdayNextDate.getMonth() + 1485 }.${tuesdayNextDate.getDate()}.${tuesdayNextDate.getFullYear()}`;486 //next tuesday FINISH487 //next wednesday START488 wednesdayNextDate = new Date(489 dateNow.getFullYear(),490 dateNow.getMonth(),491 dateNow.getDate() + 6492 );493 wednesdayNextWeek = `${494 wednesdayNextDate.getMonth() + 1495 }.${wednesdayNextDate.getDate()}.${wednesdayNextDate.getFullYear()}`;496 //next wednesday FINISH497 //next thursday START498 thursdayNextDate = new Date(499 dateNow.getFullYear(),500 dateNow.getMonth(),501 dateNow.getDate() + 7502 );503 thursdayNextWeek = `${504 thursdayNextDate.getMonth() + 1505 }.${thursdayNextDate.getDate()}.${thursdayNextDate.getFullYear()}`;506 //next thursday FINISH507 //next friday START508 fridayNextDate = new Date(509 dateNow.getFullYear(),510 dateNow.getMonth(),511 dateNow.getDate() + 8512 );513 fridayNextWeek = `${514 fridayNextDate.getMonth() + 1515 }.${fridayNextDate.getDate()}.${fridayNextDate.getFullYear()}`;516 //next friday FINISH517 break;518 case 5:519 //monday START520 mondayDate = new Date(521 dateNow.getFullYear(),522 dateNow.getMonth(),523 dateNow.getDate() - 4524 );525 mondayThisWeek = `${526 mondayDate.getMonth() + 1527 }.${mondayDate.getDate()}.${mondayDate.getFullYear()}`;528 //monday FINISH529 //tuesday START530 tuesdayDate = new Date(531 dateNow.getFullYear(),532 dateNow.getMonth(),533 dateNow.getDate() - 3534 );535 tuesdayThisWeek = `${536 tuesdayDate.getMonth() + 1537 }.${tuesdayDate.getDate()}.${tuesdayDate.getFullYear()}`;538 //tuesday FINISH539 //wednesday START540 wednesdayDate = new Date(541 dateNow.getFullYear(),542 dateNow.getMonth(),543 dateNow.getDate() - 2544 );545 wednesdayThisWeek = `${546 wednesdayDate.getMonth() + 1547 }.${wednesdayDate.getDate()}.${wednesdayDate.getFullYear()}`;548 //wednesday FINISH549 //thursday START550 thursdayDate = new Date(551 dateNow.getFullYear(),552 dateNow.getMonth(),553 dateNow.getDate() - 1554 );555 thursdayThisWeek = `${556 thursdayDate.getMonth() + 1557 }.${thursdayDate.getDate()}.${thursdayDate.getFullYear()}`;558 //thursday FINISH559 //friday START560 fridayThisWeek = `${561 dateNow.getMonth() + 1562 }.${dateNow.getDate()}.${dateNow.getFullYear()}`;563 //friday FINISH564 //next monday START565 mondayNextDate = new Date(566 dateNow.getFullYear(),567 dateNow.getMonth(),568 dateNow.getDate() + 3569 );570 mondayNextWeek = `${571 mondayNextDate.getMonth() + 1572 }.${mondayNextDate.getDate()}.${mondayNextDate.getFullYear()}`;573 //next monday FINISH574 //next tuesday START575 tuesdayNextDate = new Date(576 dateNow.getFullYear(),577 dateNow.getMonth(),578 dateNow.getDate() + 4579 );580 tuesdayNextWeek = `${581 tuesdayNextDate.getMonth() + 1582 }.${tuesdayNextDate.getDate()}.${tuesdayNextDate.getFullYear()}`;583 //next tuesday FINISH584 //next wednesday START585 wednesdayNextDate = new Date(586 dateNow.getFullYear(),587 dateNow.getMonth(),588 dateNow.getDate() + 5589 );590 wednesdayNextWeek = `${591 wednesdayNextDate.getMonth() + 1592 }.${wednesdayNextDate.getDate()}.${wednesdayNextDate.getFullYear()}`;593 //next wednesday FINISH594 //next thursday START595 thursdayNextDate = new Date(596 dateNow.getFullYear(),597 dateNow.getMonth(),598 dateNow.getDate() + 6599 );600 thursdayNextWeek = `${601 thursdayNextDate.getMonth() + 1602 }.${thursdayNextDate.getDate()}.${thursdayNextDate.getFullYear()}`;603 //next thursday FINISH604 //next friday START605 fridayNextDate = new Date(606 dateNow.getFullYear(),607 dateNow.getMonth(),608 dateNow.getDate() + 7609 );610 fridayNextWeek = `${611 fridayNextDate.getMonth() + 1612 }.${fridayNextDate.getDate()}.${fridayNextDate.getFullYear()}`;613 //next friday FINISH614 break;615 case 6:616 //monday START617 mondayDate = new Date(618 dateNow.getFullYear(),619 dateNow.getMonth(),620 dateNow.getDate() + 2621 );622 mondayThisWeek = `${623 mondayDate.getMonth() + 1624 }.${mondayDate.getDate()}.${mondayDate.getFullYear()}`;625 //monday FINISH626 //tuesday START627 tuesdayDate = new Date(628 dateNow.getFullYear(),629 dateNow.getMonth(),630 dateNow.getDate() + 3631 );632 tuesdayThisWeek = `${633 tuesdayDate.getMonth() + 1634 }.${tuesdayDate.getDate()}.${tuesdayDate.getFullYear()}`;635 //tuesday FINISH636 //wednesday START637 wednesdayDate = new Date(638 dateNow.getFullYear(),639 dateNow.getMonth(),640 dateNow.getDate() + 4641 );642 wednesdayThisWeek = `${643 wednesdayDate.getMonth() + 1644 }.${wednesdayDate.getDate()}.${wednesdayDate.getFullYear()}`;645 //wednesday FINISH646 //thursday START647 thursdayDate = new Date(648 dateNow.getFullYear(),649 dateNow.getMonth(),650 dateNow.getDate() + 5651 );652 thursdayThisWeek = `${653 thursdayDate.getMonth() + 1654 }.${thursdayDate.getDate()}.${thursdayDate.getFullYear()}`;655 //thursday FINISH656 //friday START657 fridayDate = new Date(658 dateNow.getFullYear(),659 dateNow.getMonth(),660 dateNow.getDate() + 6661 );662 fridayThisWeek = `${663 fridayDate.getMonth() + 1664 }.${fridayDate.getDate()}.${fridayDate.getFullYear()}`;665 //friday FINISH666 //next monday START667 mondayNextDate = new Date(668 dateNow.getFullYear(),669 dateNow.getMonth(),670 dateNow.getDate() + 9671 );672 mondayNextWeek = `${673 mondayNextDate.getMonth() + 1674 }.${mondayNextDate.getDate()}.${mondayNextDate.getFullYear()}`;675 //next monday FINISH676 //next tuesday START677 tuesdayNextDate = new Date(678 dateNow.getFullYear(),679 dateNow.getMonth(),680 dateNow.getDate() + 10681 );682 tuesdayNextWeek = `${683 tuesdayNextDate.getMonth() + 1684 }.${tuesdayNextDate.getDate()}.${tuesdayNextDate.getFullYear()}`;685 //next tuesday FINISH686 //next wednesday START687 wednesdayNextDate = new Date(688 dateNow.getFullYear(),689 dateNow.getMonth(),690 dateNow.getDate() + 11691 );692 wednesdayNextWeek = `${693 wednesdayNextDate.getMonth() + 1694 }.${wednesdayNextDate.getDate()}.${wednesdayNextDate.getFullYear()}`;695 //next wednesday FINISH696 //next thursday START697 thursdayNextDate = new Date(698 dateNow.getFullYear(),699 dateNow.getMonth(),700 dateNow.getDate() + 12701 );702 thursdayNextWeek = `${703 thursdayNextDate.getMonth() + 1704 }.${thursdayNextDate.getDate()}.${thursdayNextDate.getFullYear()}`;705 //next thursday FINISH706 //next friday START707 fridayNextDate = new Date(708 dateNow.getFullYear(),709 dateNow.getMonth(),710 dateNow.getDate() + 13711 );712 fridayNextWeek = `${713 fridayNextDate.getMonth() + 1714 }.${fridayNextDate.getDate()}.${fridayNextDate.getFullYear()}`;715 //next friday FINISH716 break;717 default:718 break;719 }720 //Ñ Ð¿Ð¾Ð½ÐµÐ´Ð»Ñника по пÑÑниÑÑ Ð²ÑÐ²Ð¾Ð´Ð¸Ñ ÑÑÑ Ð½ÐµÐ´ÐµÐ»Ñ + ÑледÑÑÑÑÑ721 //вÑÑ
однÑе не ÑÑиÑаÑÑÑÑ722 // в ÑÑббоÑÑ Ð¸ воÑкÑеÑенÑе вÑÐ²Ð¾Ð´Ð¸Ñ ÑледÑÑÑÑ Ð½ÐµÐ´ÐµÐ»Ñ + ÑеÑез однÑ723 //Ñоже без вÑÑ
однÑÑ
724 return [725 mondayThisWeek,726 tuesdayThisWeek,727 wednesdayThisWeek,728 thursdayThisWeek,729 fridayThisWeek,730 mondayNextWeek,731 tuesdayNextWeek,732 wednesdayNextWeek,733 thursdayNextWeek,734 fridayNextWeek,735 ];736};737//get last elem from DB738export const lastElementFromDataBase = (obj) =>739 obj.data[Object.keys(obj.data)[Object.keys(obj.data).length - 1]];740//generate empty week741export const generateEmpryWeek = () => [742 {743 a: {744 userId: "",745 text: "",746 },747 b: {748 userId: "",749 text: "",750 },751 c: {752 userId: "",753 text: "",754 },755 d: {756 userId: "",757 text: "",758 },759 e: {760 userId: "",761 text: "",762 },763 f: {764 userId: "",765 text: "",766 },767 g: {768 userId: "",769 text: "",770 },771 h: {772 userId: "",773 text: "",774 },775 i: {776 userId: "",777 text: "",778 },779 j: {780 userId: "",781 text: "",782 },783 k: {784 userId: "",785 text: "",786 },787 l: {788 userId: "",789 text: "",790 },791 m: {792 userId: "",793 text: "",794 },795 n: {796 userId: "",797 text: "",798 },799 },800 {801 a: {802 userId: "",803 text: "",804 },805 b: {806 userId: "",807 text: "",808 },809 c: {810 userId: "",811 text: "",812 },813 d: {814 userId: "",815 text: "",816 },817 e: {818 userId: "",819 text: "",820 },821 f: {822 userId: "",823 text: "",824 },825 g: {826 userId: "",827 text: "",828 },829 h: {830 userId: "",831 text: "",832 },833 i: {834 userId: "",835 text: "",836 },837 j: {838 userId: "",839 text: "",840 },841 k: {842 userId: "",843 text: "",844 },845 l: {846 userId: "",847 text: "",848 },849 m: {850 userId: "",851 text: "",852 },853 n: {854 userId: "",855 text: "",856 },857 },858 {859 a: {860 userId: "",861 text: "",862 },863 b: {864 userId: "",865 text: "",866 },867 c: {868 userId: "",869 text: "",870 },871 d: {872 userId: "",873 text: "",874 },875 e: {876 userId: "",877 text: "",878 },879 f: {880 userId: "",881 text: "",882 },883 g: {884 userId: "",885 text: "",886 },887 h: {888 userId: "",889 text: "",890 },891 i: {892 userId: "",893 text: "",894 },895 j: {896 userId: "",897 text: "",898 },899 k: {900 userId: "",901 text: "",902 },903 l: {904 userId: "",905 text: "",906 },907 m: {908 userId: "",909 text: "",910 },911 n: {912 userId: "",913 text: "",914 },915 },916 {917 a: {918 userId: "",919 text: "",920 },921 b: {922 userId: "",923 text: "",924 },925 c: {926 userId: "",927 text: "",928 },929 d: {930 userId: "",931 text: "",932 },933 e: {934 userId: "",935 text: "",936 },937 f: {938 userId: "",939 text: "",940 },941 g: {942 userId: "",943 text: "",944 },945 h: {946 userId: "",947 text: "",948 },949 i: {950 userId: "",951 text: "",952 },953 j: {954 userId: "",955 text: "",956 },957 k: {958 userId: "",959 text: "",960 },961 l: {962 userId: "",963 text: "",964 },965 m: {966 userId: "",967 text: "",968 },969 n: {970 userId: "",971 text: "",972 },973 },974 {975 a: {976 userId: "",977 text: "",978 },979 b: {980 userId: "",981 text: "",982 },983 c: {984 userId: "",985 text: "",986 },987 d: {988 userId: "",989 text: "",990 },991 e: {992 userId: "",993 text: "",994 },995 f: {996 userId: "",997 text: "",998 },999 g: {1000 userId: "",1001 text: "",1002 },1003 h: {1004 userId: "",1005 text: "",1006 },1007 i: {1008 userId: "",1009 text: "",1010 },1011 j: {1012 userId: "",1013 text: "",1014 },1015 k: {1016 userId: "",1017 text: "",1018 },1019 l: {1020 userId: "",1021 text: "",1022 },1023 m: {1024 userId: "",1025 text: "",1026 },1027 n: {1028 userId: "",1029 text: "",1030 },1031 },1032];1033//delete prev states from FireBase1034export const deletePrevStatesFromDB = async () => {1035 try {1036 const response = await axios.get(1037 "https://react-rooms-reserve.firebaseio.com/.json"1038 );1039 for (let i = 0; i < Object.keys(response.data).length; i++) {1040 const responseObj = await axios.get(1041 `https://react-rooms-reserve.firebaseio.com/${1042 Object.keys(response.data)[i]1043 }.json`1044 );1045 for (let j = 0; j < Object.keys(responseObj.data).length - 1; j++) {1046 await axios.delete(1047 `https://react-rooms-reserve.firebaseio.com/${1048 Object.keys(response.data)[i]1049 }/${Object.keys(responseObj.data)[j]}.json`1050 );1051 }1052 }1053 } catch (error) {1054 console.log(error);1055 }...
date-filter.component.ts
Source:date-filter.component.ts
1import { Component, OnInit, ViewEncapsulation, Input } from '@angular/core';2import { Router, Params, ActivatedRoute } from '@angular/router';3import { DatePipe } from '@angular/common';4import { cloneDeep } from 'lodash';5@Component({6 selector: 'app-date-filter-layout',7 templateUrl: './date-filter.component.html',8 encapsulation: ViewEncapsulation.None,9 providers: [10 DatePipe11 ]12})13export class DateFilterComponent implements OnInit {14 // Declarations variable15 currentUrl: string;16 params: any = {};17 // Filters18 filters = [19 {20 name: 'Tất Cả',21 value: 'all',22 active: true,23 },24 {25 name: 'Hôm qua',26 value: 'yesterday',27 active: false,28 },29 {30 name: 'Hôm nay',31 value: 'today',32 active: false,33 },34 {35 name: 'Tuần nà y',36 value: 'this_week',37 active: false,38 },39 {40 name: 'Tuần trÆ°á»c',41 value: 'last_week',42 active: false,43 },44 {45 name: 'Tháng nà y',46 value: 'this_month',47 active: false,48 },49 {50 name: 'Tháng trÆ°á»c',51 value: 'last_month',52 active: false,53 }54 ];55 constructor(56 private route: ActivatedRoute,57 private datePipe: DatePipe,58 private router: Router,59 ) {60 this.currentUrl = this.router.url.split('?')[0];61 }62 ngOnInit() {63 this.route.queryParamMap.subscribe(async (queryParams: Params) => {64 this.params = queryParams.params;65 });66 }67 /**68 * Change filter69 * @param {*} type70 */71 onChange(type) {72 try {73 let dateNow = new Date();74 let start = null;75 let end = null;76 switch (type) {77 case 'today':78 start = this.datePipe.transform(dateNow, 'MM/dd/yyyy');79 end = this.datePipe.transform(dateNow, 'MM/dd/yyyy');80 break;81 case 'yesterday':82 dateNow = new Date(dateNow.getFullYear(), dateNow.getMonth(), dateNow.getDate() - 1);83 start = this.datePipe.transform(dateNow, 'MM/dd/yyyy');84 end = this.datePipe.transform(dateNow, 'MM/dd/yyyy');85 break;86 case 'this_week': case 'last_week':87 dateNow = type === 'this_week'88 ? new Date(dateNow.getFullYear(), dateNow.getMonth(), dateNow.getDate())89 : new Date(dateNow.getFullYear(), dateNow.getMonth(), dateNow.getDate() - 7);90 start = this.datePipe.transform(91 new Date(dateNow.setDate(dateNow.getDate() - dateNow.getDay())),92 'MM/dd/yyyy'93 );94 end = this.datePipe.transform(95 new Date(dateNow.setDate(dateNow.getDate() - dateNow.getDay() + 6)),96 'MM/dd/yyyy'97 );98 break;99 case 'this_month': case 'last_month':100 dateNow = type === 'this_month'101 ? new Date(dateNow.getFullYear(), dateNow.getMonth(), dateNow.getDate())102 : new Date(dateNow.getFullYear(), dateNow.getMonth() - 1, dateNow.getDate());103 start = this.datePipe.transform(104 new Date(dateNow.getFullYear(), dateNow.getMonth(), 1),105 'MM/dd/yyyy'106 );107 this.datePipe.transform(108 new Date(dateNow.getFullYear(), dateNow.getMonth() + 1, 0),109 'MM/dd/yyyy'110 );111 break;112 case 'this_year': case 'last_year':113 dateNow = type === 'this_year'114 ? new Date(dateNow.getFullYear(), dateNow.getMonth(), dateNow.getDate())115 : new Date(dateNow.getFullYear() - 1, dateNow.getMonth(), dateNow.getDate());116 start = this.datePipe.transform(117 new Date(dateNow.getFullYear(), dateNow.getMonth(), 1),118 'MM/dd/yyyy'119 );120 end = this.datePipe.transform(121 new Date(dateNow.getFullYear(), dateNow.getMonth() + 1, 0),122 'MM/dd/yyyy'123 );124 break;125 default: break;126 }127 // navigate128 this.onNavigate(start, end);129 } catch (ex) {130 throw new Error(ex);131 }132 }133 /**134 * Select date135 * @param {*} date136 */137 onSelectDate(date) {138 const start = this.datePipe.transform(date[0], 'MM/dd/yyyy');139 const end = this.datePipe.transform(date[1], 'MM/dd/yyyy');140 this.onNavigate(start, end);141 }142 /**143 * Navigate144 * @param {*} start145 * @param {*} end146 */147 onNavigate(start: string, end: string) {148 const params = cloneDeep(this.params);149 return this.router.navigate(150 [this.currentUrl],151 {152 queryParams: Object.assign(153 params,154 {155 end_time: end,156 start_time: start157 }158 )159 }160 );161 }...
WeekDay.js
Source:WeekDay.js
1import React from "react";2export const WeekDay = () => {3 const [seg, setSeg] = React.useState(null);4 const [ter, setTer] = React.useState(null);5 const [qua, setQua] = React.useState(null);6 const [qui, setQui] = React.useState(null);7 const [sex, setSex] = React.useState(null);8 React.useEffect(() => {9 const getWeekDay = () => {10 const dateNow = new Date();11 if (dateNow.getDay() === 0) dateNow.setDate(dateNow.getDate() + 1);12 if (dateNow.getDay() === 1) dateNow.setDate(dateNow.getDate());13 if (dateNow.getDay() === 2) dateNow.setDate(dateNow.getDate() - 1);14 if (dateNow.getDay() === 3) dateNow.setDate(dateNow.getDate() - 2);15 if (dateNow.getDay() === 4) dateNow.setDate(dateNow.getDate() - 3);16 if (dateNow.getDay() === 5) dateNow.setDate(dateNow.getDate() - 4);17 if (dateNow.getDay() === 6) dateNow.setDate(dateNow.getDate() + 2);18 const dateSeg = dateNow.toLocaleDateString();19 setSeg(dateSeg);20 dateNow.setDate(dateNow.getDate() + 1);21 const dateTer = dateNow.toLocaleDateString();22 setTer(dateTer);23 dateNow.setDate(dateNow.getDate() + 1);24 const dateQua = dateNow.toLocaleDateString();25 setQua(dateQua);26 dateNow.setDate(dateNow.getDate() + 1);27 const dateQui = dateNow.toLocaleDateString();28 setQui(dateQui);29 dateNow.setDate(dateNow.getDate() + 1);30 const dateSex = dateNow.toLocaleDateString();31 setSex(dateSex);32 };33 getWeekDay();34 }, [setSeg, setTer, setQua, setQui, setSex]);35 return { seg, ter, qua, qui, sex };...
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) {4 console.log('Error: ' + err);5 } else {6 console.log('Test ID: ' + data.data.testId);7 }8});9var wpt = new WebPageTest('www.webpagetest.org');10}, function(err, data) {11 if (err) {12 console.log('Error: ' + err);13 } else {14 console.log('Test ID: ' + data.data.testId);15 }16});17var wpt = new WebPageTest('www.webpagetest.org');18}, function(err, data) {19 if (err) {20 console.log('Error: ' + err);21 } else {22 console.log('Test ID: ' + data.data.testId);23 }24});25var wpt = new WebPageTest('www.webpagetest.org');26}, function(err, data) {27 if (err) {28 console.log('Error: ' + err);29 } else {30 console.log('Test ID: ' + data.data.testId);31 }32});33var wpt = new WebPageTest('www.webpagetest.org');34}, function(err, data) {35 if (err) {
Using AI Code Generation
1var wpt = require('wpt');2var dateNow = wpt.dateNow();3var wpt = require('wpt');4var dateNow = wpt.dateNow();5var wpt = require('wpt');6var dateNow = wpt.dateNow();7var wpt = require('wpt');8var dateNow = wpt.dateNow();9var wpt = require('wpt');10var dateNow = wpt.dateNow();11var wpt = require('wpt');12var dateNow = wpt.dateNow();13var wpt = require('wpt');14var dateNow = wpt.dateNow();15var wpt = require('wpt');16var dateNow = wpt.dateNow();17var wpt = require('wpt');18var dateNow = wpt.dateNow();19var wpt = require('wpt');20var dateNow = wpt.dateNow();21var wpt = require('wpt');
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3var testOptions = {4};5wpt.runTest(testUrl, testOptions, function(err, data) {6 if (err) {7 console.log(err);8 }9 else {10 console.log('Test status: ' + data.statusText);11 var testId = data.data.testId;12 wpt.getTestResults(testId, function(err, data) {13 if (err) {14 console.log(err);15 }16 else {17 console.log('Test results: ' + data.statusText);18 }19 });20 }21});22Copyright (c) 2014-2016 Patrick Meenan
Using AI Code Generation
1var date = new Date();2var timestamp = date.getTime();3return timestamp;4var date = new Date();5var timestamp = date.getTime();6return timestamp;7var date = new Date();8var timestamp = date.getTime();9return timestamp;10var date = new Date();11var timestamp = date.getTime();12return timestamp;13var date = new Date();14var timestamp = date.getTime();15return timestamp;16var date = new Date();17var timestamp = date.getTime();18return timestamp;19var date = new Date();20var timestamp = date.getTime();21return timestamp;22var date = new Date();23var timestamp = date.getTime();24return timestamp;25var date = new Date();26var timestamp = date.getTime();27return timestamp;28var date = new Date();29var timestamp = date.getTime();30return timestamp;31var date = new Date();32var timestamp = date.getTime();33return timestamp;34var date = new Date();35var timestamp = date.getTime();36return timestamp;37var date = new Date();38var timestamp = date.getTime();39return timestamp;40var date = new Date();41var timestamp = date.getTime();42return timestamp;
Using AI Code Generation
1var dateNow = require('wpt').dateNow;2console.log(dateNow());3var wpt = require('wpt');4console.log(wpt.dateNow());5var wpt = require('wpt');6console.log(wpt.dateNow());7var wpt = require('wpt');8console.log(wpt.dateNow());9var wpt = require('wpt');10console.log(wpt.dateNow());11var wpt = require('wpt');12console.log(wpt.dateNow());13var wpt = require('wpt');14console.log(wpt.dateNow());15var wpt = require('wpt');16console.log(wpt.dateNow());17var wpt = require('wpt');18console.log(wpt.dateNow());19var wpt = require('wpt');20console.log(wpt.dateNow());21var wpt = require('wpt');22console.log(wpt.dateNow());
Using AI Code Generation
1console.log(date);2wpt.setTimeout(function(){3 console.log("Hello World");4}, 5000);5var interval = wpt.setInterval(function(){6 console.log("Hello World");7}, 5000);8wpt.clearInterval(interval);
Using AI Code Generation
1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.dateNow(function(err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data);8 }9});10var wpt = require('wpt');11var wpt = new WebPageTest('www.webpagetest.org');12wpt.getLocations(function(err, data) {13 if (err) {14 console.log(err);15 } else {16 console.log(data);17 }18});
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!