Home | Trees | Indices | Help |
|
---|
|
1 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Rickard Lindberg, Roger Lindberg 2 # 3 # This file is part of Timeline. 4 # 5 # Timeline is free software: you can redistribute it and/or modify 6 # it under the terms of the GNU General Public License as published by 7 # the Free Software Foundation, either version 3 of the License, or 8 # (at your option) any later version. 9 # 10 # Timeline is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with Timeline. If not, see <http://www.gnu.org/licenses/>. 17 18 19 import wx 20 21 from timelinelib.calendar.coptic.coptic import CopticDateTime 22 from timelinelib.calendar.coptic.time import CopticDelta 23 from timelinelib.calendar.coptic.timepicker.datecontroller import CopticDatePickerController 24 from timelinelib.calendar.coptic.timetype import CopticTimeType 25 from timelinelib.wxgui.components.textctrl import TextCtrl 26 2729102 10331 wx.Panel.__init__(self, parent) 32 self._controller = CopticDatePickerController(self) 33 self._create_gui(date_formatter) 34 self._controller.on_init( 35 date_formatter, 36 DateModifier() 37 )38 4345 self.date_text = TextCtrl( 46 self, 47 style=wx.TE_PROCESS_ENTER, 48 fit_text=self._format_sample_date(date_formatter) 49 ) 50 self.date_text.Bind(wx.EVT_CHAR, self._controller.on_char) 51 self.date_text.Bind(wx.EVT_TEXT, self._controller.on_text)52 5860 sizer = wx.BoxSizer(wx.HORIZONTAL) 61 sizer.Add(self.date_text, flag=wx.EXPAND, proportion=1) 62 sizer.Add(self.bc_button, flag=wx.EXPAND) 63 self.SetSizer(sizer)6466 return date_formatter.format( 67 CopticDateTime.from_time( 68 CopticTimeType().now() 69 ).to_date_tuple() 70 )[0]7173 return self._controller.get_coptic_date()74 7779 return self.date_text.GetValue()8082 x = self.date_text.GetInsertionPoint() 83 self.date_text.SetValue(text) 84 self.date_text.SetInsertionPoint(x)85 8991 return self.date_text.GetInsertionPoint()9294 return self.bc_button.GetValue()95 98105162107 max_year = CopticDateTime.from_time(CopticTimeType().get_max_time()).year 108 year, month, day = date 109 if year < max_year - 1: 110 return self._set_valid_day(year + 1, month, day) 111 return date112114 max_year = CopticDateTime.from_time(CopticTimeType().get_max_time()).year 115 year, month, day = date 116 if month < 13: 117 return self._set_valid_day(year, month + 1, day) 118 elif year < max_year - 1: 119 return self._set_valid_day(year + 1, 1, day) 120 return date121123 year, month, day = date 124 time = CopticDateTime.from_ymd(year, month, day).to_time() 125 if time < CopticTimeType().get_max_time() - CopticDelta.from_days(1): 126 return CopticDateTime.from_time(time + CopticDelta.from_days(1)).to_date_tuple() 127 return date128130 year, month, day = date 131 if year > CopticDateTime.from_time(CopticTimeType().get_min_time()).year: 132 return self._set_valid_day(year - 1, month, day) 133 return date134136 year, month, day = date 137 if month > 1: 138 return self._set_valid_day(year, month - 1, day) 139 elif year > CopticDateTime.from_time(CopticTimeType().get_min_time()).year: 140 return self._set_valid_day(year - 1, 13, day) 141 return date142144 year, month, day = date 145 if day > 1: 146 return self._set_valid_day(year, month, day - 1) 147 elif month > 1: 148 return self._set_valid_day(year, month - 1, 30) 149 elif year > CopticDateTime.from_time(CopticTimeType().get_min_time()).year: 150 return self._set_valid_day(year - 1, 12, 30) 151 return date152154 done = False 155 while not done: 156 try: 157 date = CopticDateTime.from_ymd(new_year, new_month, new_day) 158 done = True 159 except Exception: 160 new_day -= 1 161 return date.to_date_tuple()
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri Sep 13 01:55:28 2019 | http://epydoc.sourceforge.net |