693 | | for name in nameddates : |
694 | | if dateval.startswith(name) : |
695 | | try : |
696 | | offset = int(dateval[len(name):]) |
| 693 | if dateval : |
| 694 | for name in nameddates : |
| 695 | if dateval.startswith(name) : |
| 696 | try : |
| 697 | offset = int(dateval[len(name):]) |
| 698 | except : |
| 699 | offset = 0 |
| 700 | dateval = dateval[:len(name)] |
| 701 | if limit == "start" : |
| 702 | if dateval == "yesterday" : |
| 703 | dateval = (now - 1 + offset).Format("%Y%m%d000000") |
| 704 | elif dateval == "today" : |
| 705 | dateval = (now + offset).Format("%Y%m%d000000") |
| 706 | elif dateval == "now" : |
| 707 | dateval = (now + offset).Format("%Y%m%d%H%M%S") |
| 708 | else : # tomorrow |
| 709 | dateval = (now + 1 + offset).Format("%Y%m%d000000") |
| 710 | else : |
| 711 | if dateval == "yesterday" : |
| 712 | dateval = (now - 1 + offset).Format("%Y%m%d235959") |
| 713 | elif dateval == "today" : |
| 714 | dateval = (now + offset).Format("%Y%m%d235959") |
| 715 | elif dateval == "now" : |
| 716 | dateval = (now + offset).Format("%Y%m%d%H%M%S") |
| 717 | else : # tomorrow |
| 718 | dateval = (now + 1 + offset).Format("%Y%m%d235959") |
| 719 | break |
| 720 | |
| 721 | if not dateval.isdigit() : |
| 722 | dateval = None |
| 723 | else : |
| 724 | lgdateval = len(dateval) |
| 725 | if lgdateval == 4 : |
| 726 | if limit == "start" : |
| 727 | dateval = "%s0101 00:00:00" % dateval |
| 728 | else : |
| 729 | dateval = "%s1231 23:59:59" % dateval |
| 730 | elif lgdateval == 6 : |
| 731 | if limit == "start" : |
| 732 | dateval = "%s01 00:00:00" % dateval |
| 733 | else : |
| 734 | mxdate = DateTime.ISO.ParseDateTime("%s01 00:00:00" % dateval) |
| 735 | dateval = "%s%02i 23:59:59" % (dateval, mxdate.days_in_month) |
| 736 | elif lgdateval == 8 : |
| 737 | if limit == "start" : |
| 738 | dateval = "%s 00:00:00" % dateval |
| 739 | else : |
| 740 | dateval = "%s 23:59:59" % dateval |
| 741 | elif lgdateval == 10 : |
| 742 | if limit == "start" : |
| 743 | dateval = "%s %s:00:00" % (dateval[:8], dateval[8:]) |
| 744 | else : |
| 745 | dateval = "%s %s:59:59" % (dateval[:8], dateval[8:]) |
| 746 | elif lgdateval == 12 : |
| 747 | if limit == "start" : |
| 748 | dateval = "%s %s:%s:00" % (dateval[:8], dateval[8:10], dateval[10:]) |
| 749 | else : |
| 750 | dateval = "%s %s:%s:59" % (dateval[:8], dateval[8:10], dateval[10:]) |
| 751 | elif lgdateval == 14 : |
| 752 | dateval = "%s %s:%s:%s" % (dateval[:8], dateval[8:10], dateval[10:12], dateval[12:]) |
| 753 | else : |
| 754 | dateval = None |
| 755 | try : |
| 756 | DateTime.ISO.ParseDateTime(dateval) |
698 | | offset = 0 |
699 | | dateval = dateval[:len(name)] |
700 | | if limit == "start" : |
701 | | if dateval == "yesterday" : |
702 | | dateval = (now - 1 + offset).Format("%Y%m%d000000") |
703 | | elif dateval == "today" : |
704 | | dateval = (now + offset).Format("%Y%m%d000000") |
705 | | elif dateval == "now" : |
706 | | dateval = (now + offset).Format("%Y%m%d%H%M%S") |
707 | | else : # tomorrow |
708 | | dateval = (now + 1 + offset).Format("%Y%m%d000000") |
709 | | else : |
710 | | if dateval == "yesterday" : |
711 | | dateval = (now - 1 + offset).Format("%Y%m%d235959") |
712 | | elif dateval == "today" : |
713 | | dateval = (now + offset).Format("%Y%m%d235959") |
714 | | elif dateval == "now" : |
715 | | dateval = (now + offset).Format("%Y%m%d%H%M%S") |
716 | | else : # tomorrow |
717 | | dateval = (now + 1 + offset).Format("%Y%m%d235959") |
718 | | break |
719 | | |
720 | | if not dateval.isdigit() : |
721 | | dateval = None |
722 | | else : |
723 | | lgdateval = len(dateval) |
724 | | if lgdateval == 4 : |
725 | | if limit == "start" : |
726 | | dateval = "%s0101 00:00:00" % dateval |
727 | | else : |
728 | | dateval = "%s1231 23:59:59" % dateval |
729 | | elif lgdateval == 6 : |
730 | | if limit == "start" : |
731 | | dateval = "%s01 00:00:00" % dateval |
732 | | else : |
733 | | mxdate = DateTime.ISO.ParseDateTime("%s01 00:00:00" % dateval) |
734 | | dateval = "%s%02i 23:59:59" % (dateval, mxdate.days_in_month) |
735 | | elif lgdateval == 8 : |
736 | | if limit == "start" : |
737 | | dateval = "%s 00:00:00" % dateval |
738 | | else : |
739 | | dateval = "%s 23:59:59" % dateval |
740 | | elif lgdateval == 10 : |
741 | | if limit == "start" : |
742 | | dateval = "%s %s:00:00" % (dateval[:8], dateval[8:]) |
743 | | else : |
744 | | dateval = "%s %s:59:59" % (dateval[:8], dateval[8:]) |
745 | | elif lgdateval == 12 : |
746 | | if limit == "start" : |
747 | | dateval = "%s %s:%s:00" % (dateval[:8], dateval[8:10], dateval[10:]) |
748 | | else : |
749 | | dateval = "%s %s:%s:59" % (dateval[:8], dateval[8:10], dateval[10:]) |
750 | | elif lgdateval == 14 : |
751 | | dateval = "%s %s:%s:%s" % (dateval[:8], dateval[8:10], dateval[10:12], dateval[12:]) |
752 | | else : |
753 | | dateval = None |
754 | | try : |
755 | | DateTime.ISO.ParseDateTime(dateval) |
756 | | except : |
757 | | dateval = None |
758 | | datedict[limit] = dateval |
| 758 | dateval = None |
| 759 | datedict[limit] = dateval |