def __parse_calendar(self):
        """
        Uses a bs4 ResultSet of the <td> tags representing days currently dis-
        played on the calendar to set calendarattributes. Items have the format
        of `<td class="[class]">[D]</td>` where
         - [D] is the one- or two-digit day (as a string) and
         - [class] is one of
             "old day"          = a day with archives but in a prior month
                                  (clicking will refresh the calendar)
             "day"              = a past day in the current month
             "active day"       = the day currently displayed in the ATT
             "disabled day"     = a day for which no archive is available in a
                                  month (past or future) that has other days
                                  with archives. For example, if today is July
                                  27, July 28-31 will be disabled days, as will
                                  January 1-26 (since the archive goes back only
                                  180 days). December 31 would be an "old dis-
                                  abled day".
             "new disabled day" = a day in a future month
             "old disabled day" = see explanation in "disabled day"


        """
        if self.verbose: print('\tParsing calendar...')

        # Get the tags representing the days currently displayed on the calendar
        days_on_calendar = self.calendar_soup.find_all('td')

        # Get the month & year currently displayed
        month, year = self.calendar_soup.find('th', {
            'class': 'datepicker-switch'
        }).text.split(' ')

        displayed_month = _MONTHS.index(month)
        displayed_year = int(year)

        # Parse the various calendar attributes
        active_day = int([
            day.text for day in days_on_calendar
            if (day['class'][0] == 'active')
        ][0])

        month_max_day = int([
            day.text for day in days_on_calendar
            if (day['class'][0] == 'day') or (day['class'][0] == 'active')
        ][::-1][0])

        month_min_day = int(self.__parse_month_min_day(days_on_calendar))

        # Set class attributes
        self.active_date = _date(displayed_year, displayed_month, active_day)
        self.month_min_date = _date(displayed_year, displayed_month,
                                    month_min_day)
        self.month_max_date = _date(displayed_year, displayed_month,
                                    month_max_day)
Example #2
0
def date(ctx, year, month, day):
    """
    Defines a date value
    """
    return _date(conversions.to_integer(year, ctx),
                 conversions.to_integer(month, ctx),
                 conversions.to_integer(day, ctx))
Example #3
0
    def cast_value(self, value, data_type):
        self._can_cast_or_throw(value, data_type)

        if isinstance(data_type, String):
            datetime = _datetime.strptime(value, '%Y-%m-%d')
            return _date(datetime.year, datetime.month, datetime.day)
        elif isinstance(data_type, Timestamp):
            return value.to_pydatetime().date()
        return value
def add_completed_entry(request, proj_pk, role_id):
    role = Role.objects.get(id=role_id)
    questionnaire = role.get_questionnaire()
    questions = questionnaire.get_questions()
    QuestionFormset = formset_factory(QuestionForm,
            extra=5,
            max_num=len(questions))
    QuestionFormset.form = staticmethod(curry(QuestionForm, role))
    if request.method == 'POST':
        d = request.POST.get('date').split('-')
        date = _date(year=int(d[0]), month=int(d[1]), day=int(d[2]))
        uid_form = UIDForm(role, date, request.POST, request.FILES)
        formset = QuestionFormset()

        if request.is_ajax():
            if uid_form.is_valid():
                uid_status=uid_form.save()
            else:
                return HttpResponse('Error')
            QuestionFormset.form = staticmethod(curry(QuestionForm, role,
                uid_status))
            formset = QuestionFormset(request.POST, request.FILES)
            if formset.is_valid():
                for form in formset:
                    form.save()
                return HttpResponse('Success')
            else:
                return HttpResponse('Error')

        if uid_form.is_valid():
            uid_status = uid_form.save()
        else:
            return render(request, 'main/add_completed_entry.html',
                    {'uid_form':uid_form, 'formset':formset,
                        'date':date, 'role':role})

        QuestionFormset.form = staticmethod(curry(QuestionForm, role,
            uid_status))

        formset = QuestionFormset(request.POST, request.FILES)
        if formset.is_valid():
            for form in formset:
                form.save()
            return HttpResponseRedirect(reverse('add-completed-entry-done',
                kwargs={'role_id':role.id}))
        else:
            return render(request, 'main/add_completed_entry.html',
                    {'uid_form':uid_form, 'formset':formset,
                        'date':date, 'role':role})
    else:
        date = _date.today() - _timedelta(days=2)
        uid_form = UIDForm(role, date)
        formset = QuestionFormset()
        return render(request, 'main/add_completed_entry.html',
                {'uid_form':uid_form, 'formset':formset,
                    'date':date, 'role':role})
Example #5
0
    def form_valid(self, form):
        spreadsheet = form.cleaned_data['spreadsheet']
        w = xlrd.open_workbook(filename=None, file_contents=spreadsheet.read())
        sheet = w.sheet_by_index(0)

        header = [
            unicode(sheet.cell_value(0, i)).lower()
            for i in range(0, sheet.ncols)
        ]
        rows = [
            dict(
                zip(header,
                    [sheet.cell_value(j, i) for i in range(0, sheet.ncols)]))
            for j in range(1, sheet.nrows)
        ]

        sample = rows[0] if rows else None
        if sample:
            if len({'refugeeid', 'as office eng', 'date',
                    'hour of day'}.intersection(sample.keys())) == 4:
                updated_count = 0
                created_count = 0
                for r in rows:
                    appointment, created = models.AppointmentSchedule.objects.get_or_create(
                        registration_number=str(int(r['refugeeid'])))
                    if type(r['date']) is float:
                        date = xlrd.xldate_as_tuple(r['date'], w.datemode)
                        date = "{} {}".format(
                            _date(*date[0:3]).isoformat(), r['hour of day'])
                        date = dateparser.parse(date)
                    else:
                        date = "{} {}".format(r['date'], r['hour of day'])
                        date = dateparser.parse(date,
                                                settings={'DATE_ORDER': 'DMY'})

                    athens = pytz.timezone("Europe/Athens")
                    date = athens.localize(date)

                    asylum_office, c = models.AsylumOffice.objects.get_or_create(
                        name=r['as office eng'])

                    appointment.date = date
                    appointment.office = asylum_office
                    appointment.save()
                    if created:
                        created_count += 1
                    else:
                        updated_count += 1
                messages.success(
                    self.request,
                    self.get_success_message(created_count, updated_count))
            else:
                messages.error(
                    self.request,
                    'An error occured while parsing uploaded file.')
        return super(ImportSpreadsheetView, self).form_valid(form)
Example #6
0
 def __init__(self, year, month=None, day=None):
     if year and month and day:
         self._date = _date(year, month, day)
         self._resolution = 3
         self.year = year
         self.month = month
         self.day = day
     elif year and month:
         self._date = _date(year, month, 1)
         self._resolution = 2
         self.year = year
         self.month = month
         self.day = None
     elif year:
         self._date = _date(year, 1, 1)
         self._resolution = 1
         self.year = year
         self.month = None
         self.day = None
def get_last_month_end(date):
    """
    :param date: 格式 20200101
    """
    from datetime import date as _date, timedelta

    date = str(date)
    year, month, day = date[:4], date[4:6], "01"
    target_next_day = _date(*map(int, [year, month, day])) - timedelta(days=1)
    return int(target_next_day.strftime("%Y%m%d"))
Example #8
0
 def __init__(self, year, month=None, day=None):
     if year and month and day:
         self._date = _date(year, month, day)
         self._resolution = 3
         self.year = year
         self.month = month
         self.day = day
     elif year and month:
         self._date = _date(year, month, 1)
         self._resolution = 2
         self.year = year
         self.month = month
         self.day = None
     elif year:
         self._date = _date(year, 1, 1)
         self._resolution = 1
         self.year = year
         self.month = None
         self.day = None
Example #9
0
def easter_sunday(year):
    k = year / 100
    m = 15 + (3 * k + 3) / 4 - (8 * k + 13) / 25
    s = 2 - (3 * k + 3) / 4
    a = year % 19
    d = (19 * a + m) % 30
    r = (d + a / 11) / 29
    og = 21 + d - r
    sz = 7 - (year + year / 4 + s) % 7
    oe = 7 - (og - sz) % 7
    os = og + oe
    return _date(year, 3, 1) + timedelta(days=os - 1)
Example #10
0
    def _create_date_range_seq(self, date):
        year = fields.Date.from_string(date).strftime('%Y')
        month = fields.Date.from_string(date).strftime('%m')

        date_from = '{}-01-01'.format(year)
        date_to = '{}-12-31'.format(year)

        if self.date_range_interval == 'monthly':
            date_from = '{year}-{month}-01'.format(year=year, month=month)
            date_to = '{}'.format(
                self.last_day_of_month(_date(
                    int(year),
                    int(month),
                    1,
                )))
        elif self.date_range_interval == 'weekly':
            date_from = fields.Date.from_string(date).strftime('%Y-%m-%d')
            date_to = datetime.strptime(date_from,
                                        '%Y-%m-%d') + timedelta(weeks=1)
        elif self.date_range_interval == 'daily':
            date_from = fields.Date.from_string(date).strftime('%Y-%m-%d')
            date_to = datetime.strptime(date_from,
                                        '%Y-%m-%d') + timedelta(days=1)

        date_range = self.env['ir.sequence.date_range'].search(
            [('sequence_id', '=', self.id), ('date_from', '>=', date),
             ('date_from', '<=', date_to)],
            order='date_from desc',
            limit=1)
        if date_range:
            date_to = datetime.strptime(date_range.date_from,
                                        '%Y-%m-%d') + timedelta(days=-1)
            date_to = date_to.strftime('%Y-%m-%d')
        date_range = self.env['ir.sequence.date_range'].search(
            [('sequence_id', '=', self.id), ('date_to', '>=', date_from),
             ('date_to', '<=', date)],
            order='date_to desc',
            limit=1)
        if date_range:
            date_from = datetime.strptime(date_range.date_to,
                                          '%Y-%m-%d') + timedelta(days=1)
            date_from = date_from.strftime('%Y-%m-%d')
        seq_date_range = self.env['ir.sequence.date_range'].sudo().create({
            'date_from':
            date_from,
            'date_to':
            date_to,
            'sequence_id':
            self.id,
        })
        return seq_date_range
Example #11
0
File: age.py Project: datakortet/dk
def years_ago(n, today=None):
    "The date that is `n` years before `today`."
    today = today or _date.today()
    pastyear = today.year - n
    _, pdays = _monthrange(pastyear, today.month)
    day_ok = today.day <= pdays
    if day_ok:
        pastday = today.day
        pastmonth = today.month
    else:
        pastday = _days_previous_month(pastyear, today.month)
        pastmonth = _past_month(today.month)
    res = _date(pastyear, pastmonth, pastday)
    return res
Example #12
0
File: age.py Project: datakortet/dk
def next_birthday(birthday, today=None):
    "Return the date of the next birthday for someone born on date `birthday`."
    if today is None:
        today = _date.today()
        
    y, m, d = birthday.year, birthday.month, birthday.day
    
    y = today.year  # find the birthday this year.

    if (today.month, today.day) > (m, d):
        # if the birthday has passed, the next one is next year
        y += 1

    if not _isleap(y) and (m, d) == (2, 29):
        # Birthdays on the 29th of February are celebrated
        # on the 28th in non-leap years.
        d = 28

    return _date(y, m, d)
Example #13
0
    def handle(self, *args, **options):
        url, = options['url']
        res = requests.get(url)
        with tempfile.NamedTemporaryFile(suffix='.xlsx') as temp:
            temp.delete = True
            with open(temp.name, 'w+') as fp:
                fp.write(res.content)

            w = xlrd.open_workbook(temp.name)

        sheet = w.sheet_by_index(0)

        header = [unicode(sheet.cell_value(0, i)).lower() for i in range(0, sheet.ncols)]
        rows = [dict(zip(header, [sheet.cell_value(j, i) for i in range(0, sheet.ncols)])) for j in
                range(1, sheet.nrows)]

        sample = rows[0] if rows else None
        print ('Loaded spreadsheet')
        if sample:
            if len({'refugeeid', 'as office eng', 'date', 'hour of day'}.intersection(sample.keys())) == 4:
                for r in rows:
                    appointment, created = models.AppointmentSchedule.objects.get_or_create(
                        registration_number=str(int(r['refugeeid'])))
                    if type(r['date']) is float:
                        date = xlrd.xldate_as_tuple(r['date'], w.datemode)
                        date = "{} {}".format(_date(*date[0:3]).isoformat(), r['hour of day'])
                        date = dateparser.parse(date)
                    else:
                        date = "{} {}".format(r['date'], r['hour of day'])
                        date = dateparser.parse(date, settings={'DATE_ORDER': 'DMY'})

                    athens = pytz.timezone("Europe/Athens")
                    date = athens.localize(date)

                    asylum_office, c = models.AsylumOffice.objects.get_or_create(name=r['as office eng'])

                    appointment.date = date
                    appointment.office = asylum_office
                    appointment.save()

                    print('Imported appointment for registration number {}'.format(appointment.registration_number))
        print('Import complete')
def add_uncompleted_entry(request, proj_pk, role_id):
    role = Role.objects.get(id=role_id)
    ErrorFormset = formset_factory(ErrorForm, extra=1,
            max_num = len(ErrorType.objects.all().filter(level=0)))
    ErrorFormset.form = staticmethod(curry(ErrorForm, role))
    if request.method == 'POST':
        d = request.POST.get('date').split('-')
        date = _date(year=int(d[0]), month=int(d[1]), day=int(d[2]))
        uid_form = UIDForm(role, date, request.POST, request.FILES)
        error_formset = ErrorFormset()

        if uid_form.is_valid():
            uid_status = uid_form.save()
        else:
            return render(request, 'main/add_uncompleted_entry.html',
                    {'uid_form':uid_form, 'error_formset':error_formset,
                        'date':date, 'role':role})

        ErrorFormset.form = staticmethod(curry(ErrorForm, role, uid_status))
        error_formset = ErrorFormset(request.POST, request.FILES)
        if error_formset.is_valid():
            for form in error_formset:
                form.save()
            return redirect(reverse('update-uids',
                            kwargs={'proj_pk':proj_pk}))
        else:
            return render(request, 'main/add_uncompleted_entry.html',
                    {'uid_form':uid_form, 'error_formset':error_formset,
                        'date':date, 'role':role})
    else:
        date = _date.today() - _timedelta(days=2)
        uid_form = UIDForm(role, date)
        error_formset = ErrorFormset()
        return render(request, 'main/add_uncompleted_entry.html',
                {'uid_form':uid_form, 'error_formset':error_formset,
                    'date':date, 'role':role})
Example #15
0
 def test_fester_Feiertag(self):
     d = _date(2015, 12, 25)
     d2 = special_days['Erster Weihnachtstag'](2015)
     self.assertEqual(d, d2)
Example #16
0
print(dt1.hour, dt1.minute, dt1.second)  # 18 0 1
print(dt1.max, dt1.min)  # 23:59:59.999999 00:00:00
dt2 = dt1.replace(hour=19)  # 19:00:01, return a new time

#
#
#
#
#
#
#
from datetime import date as _date

#
# construct a date
d1 = _date(2017, 3, 23)  # 2017-03-23 <class 'datetime.date'>
print(d1.year, d1.month, d1.day)  # 2017 3 23
d1.isoformat()  # 2017-03-23
d1.__format__('%Y/%m/%d')  # 2017/03/23 <class 'str'>
d1.weekday()  # (周)3
d1.isoweekday()  # (周)4
#
# use timestamp construct date
_date.fromtimestamp(_time.time())  # 2017-03-23 <class 'datetime.date'>
#
# date of today
_date.today()  # 2017-03-23 <class 'datetime.date'>
#
#
#
#
Example #17
0
from pathlib import Path as _Path


# Version of Midgard.
#
# This is automatically set using the bumpversion tool
__version__ = "1.1.5"


# Authors of Midgard.
_Author = _namedtuple("_Author", ["name", "email", "start", "end"])
_AUTHORS = [
    _Author("Michael Dähnn", "*****@*****.**", _date.min, _date.max),
    _Author("Ingrid Fausk", "*****@*****.**", _date.min, _date.max),
    _Author("Ann-Silje Kirkvik", "*****@*****.**", _date.min, _date.max),
    _Author("Mohammed Ouassou", "*****@*****.**", _date(2018, 9, 1), _date.max),
    _Author("Hans Sverre Smalø", "*****@*****.**", _date(2018, 12, 1), _date.max),
    _Author("Geir Arne Hjelle", "*****@*****.**", _date(2019, 2, 1), _date.max),
    # Hall of Fame
    _Author("Geir Arne Hjelle", "*****@*****.**", _date.min, _date(2019, 2, 1)),
]

__author__ = ", ".join(a.name for a in _AUTHORS if a.start < _date.today() < a.end)
__contact__ = ", ".join(a.email for a in _AUTHORS if a.start < _date.today() < a.end)


# Copyleft of the library
__copyright__ = f"2018 - {_date.today().year} Norwegian Mapping Authority"


# Update doc with info about subpackages and maintainers
Example #18
0
def first_day_of_week(week, year):  # found on stackoverflow...
    ret = timezone.datetime.strptime(
        '{year:04d}-{week:02d}-1'.format(year=year, week=week), '%Y-%W-%w')
    if _date(year, 1, 4).isoweekday() > 4:
        ret -= timezone.timedelta(days=7)
    return timezone.make_aware(ret)
def f_date(year, month, day):
    """
    Defines a date value
    """
    return _date(val_to_integer(year), val_to_integer(month), val_to_integer(day))
Example #20
0
#
# This is automatically set using the where_release tool
__version__ = "1.0.4"

# Authors of the software
_Author = _namedtuple("_Author", ["name", "email", "start", "end"])

_AUTHORS = [
    _Author("Michael Dähnn", "*****@*****.**", _date.min,
            _date.max),
    _Author("Ingrid Fausk", "*****@*****.**", _date.min,
            _date.max),
    _Author("Ann-Silje Kirkvik", "*****@*****.**", _date.min,
            _date.max),
    _Author("Mohammed Ouassou", "*****@*****.**",
            _date(2018, 9, 1), _date.max),
    # Hall of Fame
    _Author("Eirik Mysen", "*****@*****.**", _date.min,
            _date(2017, 6, 1)),
    _Author("Geir Arne Hjelle", "*****@*****.**", _date.min,
            _date(2019, 2, 1)),
]

__author__ = ", ".join(a.name for a in _AUTHORS
                       if a.start < _date.today() < a.end)
__contact__ = ", ".join(a.email for a in _AUTHORS
                        if a.start < _date.today() < a.end)

# Copyleft of the software
__copyright__ = "2015 - {} Kartverket".format(_date.today().year)
Example #21
0
def date(ctx, year, month, day):
    """
    Defines a date value
    """
    return _date(conversions.to_integer(year, ctx), conversions.to_integer(month, ctx), conversions.to_integer(day, ctx))
Example #22
0
def first_day_of_week(week, year):  # found on stackoverflow...
    ret = timezone.datetime.strptime('{year:04d}-{week:02d}-1'.format(year=year, week=week), '%Y-%W-%w')
    if _date(year, 1, 4).isoweekday() > 4:
        ret -= timezone.timedelta(days=7)
    return timezone.make_aware(ret)
Example #23
0
from pyplugs._exceptions import *  # noqa
from pyplugs._plugins import *  # noqa

# Version of PyPlugs.
#
# This is automatically set using the bumpversion tool
__version__ = "0.3.2"

# Homepage for PyPlugs
__url__ = "https://pyplugs.readthedocs.io/"

# Authors/maintainers of Pyplugs
_Author = _namedtuple("_Author", ["name", "email", "start", "end"])
_AUTHORS = [
    _Author("Geir Arne Hjelle", "*****@*****.**", _date(2019, 4, 1),
            _date.max)
]

__author__ = ", ".join(a.name for a in _AUTHORS
                       if a.start < _date.today() < a.end)
__contact__ = ", ".join(a.email for a in _AUTHORS
                        if a.start < _date.today() < a.end)


# Update doc with info about maintainers
def _update_doc(doc: str) -> str:
    """Add information to doc-string

    Args:
        doc:  The doc-string to update.
	def __init__(self, y,m,d):
		self.limits = [3,7,20,28]
		BaseControl.__init__(self, startDate=_date(y,m,d))
	def __init__(self, y,m,d):
		self.limits, self.startDate = [5,16,27,36], _date(y,m,d)
		#assert(self.check_range())
		BaseControl.__init__(self, startDate=self.startDate, Days=False)
Example #26
0
 def __init__(self, y, m, d):
     self.weeks_calc = lambda: [_fix_ctrlday(_date(y, m, d) + _timedelta(weeks=i)) for i in self.weeks_ctrls]
     super(PrePromotional, self).__init__()
	def __init__(self, y,m,d):
		self.limits, self.workindays = [9,15,20,25,30,35], False
		BaseControl.__init__(self, startDate=_date(y,m,d), Days=False)
Example #28
0
    k = year / 100
    m = 15 + (3 * k + 3) / 4 - (8 * k + 13) / 25
    s = 2 - (3 * k + 3) / 4
    a = year % 19
    d = (19 * a + m) % 30
    r = (d + a / 11) / 29
    og = 21 + d - r
    sz = 7 - (year + year / 4 + s) % 7
    oe = 7 - (og - sz) % 7
    os = og + oe
    return _date(year, 3, 1) + timedelta(days=os - 1)


special_days = {
    # Feste Feiertage
    'Neujahrstag': lambda year: _date(year, 1, 1),
    'Internationaler Frauentag': lambda year: _date(year, 3, 8),
    'Tag der Arbeit': lambda year: _date(year, 5, 1),
    'Tag der Deutschen Einheit': lambda year: _date(year, 10, 3),
    'Erster Weihnachtstag': lambda year: _date(year, 12, 25),
    'Zweiter Weihnachtstag': lambda year: _date(year, 12, 26),
    # Bewegliche Feiertage
    'Karfreitag': lambda year: easter_sunday(year) - timedelta(days=2),
    'Ostersonntag': lambda year: easter_sunday(year),
    'Ostermontag': lambda year: easter_sunday(year) + timedelta(days=1),
    'Himmelfahrt': lambda year: easter_sunday(year) + timedelta(days=39),
    'Pfingstsonntag': lambda year: easter_sunday(year) + timedelta(days=49),
    'Pfingstmontag': lambda year: easter_sunday(year) + timedelta(days=50),
}

def to_date(strDate):
	tmpDate = lambda dt: _date(int(dt[0]), int(dt[1]), int(dt[2]))
	return tmpDate(strDate.split('-'))
	def __init__(self, y,m,d):
		self.limits, self.workindays = [1,7], False
		BaseControl.__init__(self, startDate=_date(y,m,d))
Example #31
0
 def checking(self):
     pp = _date(self.year, self.month, self.day)
     days_left = (pp - _utc.now().date()).days
     days_checked = (pp - (pp - _timedelta(days=280))).days
     return True if 0 < days_left <= days_checked else False
Example #32
0
 def test_ist_Feiertag_1(self):
     d = _date(2012, 12, 26)
     self.assertTrue(is_special_day(d))
Example #33
0
File: age.py Project: datakortet/dk
def birthday_this_year(birthday, today=None):
    "Return the date of the birthday in the current year."
    if today is None:
        today = _date.today()
    return next_birthday(birthday, _date(today.year, 1, 1))
Example #34
0
 def test_ist_Feiertag_2(self):
     d = _date(2020, 5, 1)
     self.assertTrue(is_special_day(d))
Example #35
0
 def __init__(self, y, m, d):
     self.weeks_cal = lambda y, m, d: int(round((_date(y, m, d) - _utc.now().date()).days / 7.0))
     self.year, self.month, self.day = y, m, d
     assert self.checking()
     super(PreNatal, self).__init__()
Example #36
0
 def __init__(self, y, m, d):
     self.limits, self.startDate = [5, 16, 27, 36], _date(y, m, d)
     #assert(self.check_range())
     BaseControl.__init__(self, startDate=self.startDate, Days=False)
Example #37
0
from datetime import date as _date
from datetime import datetime as _datetime


# ---------- Miscellaneous ----------

WIKIA_BASE_ADDRESS = 'https://pixelstarships.fandom.com/wiki/'


# ---------- Defaults ----------

DEFAULT_FLOAT_PRECISION: int = 1


# ---------- Formatting / Parsing ----------

API_DATETIME_FORMAT_ISO: str = '%Y-%m-%dT%H:%M:%S'
API_DATETIME_FORMAT_ISO_DETAILED: str = '%Y-%m-%dT%H:%M:%S.%f'
API_DATETIME_FORMAT_CUSTOM: str = '%d.%m.%y %H:%M'


# ---------- PSS ----------

PSS_START_DATE: _date = _date(year=2016, month=1, day=6)
PSS_START_DATETIME: _datetime = _datetime(year=2016, month=1, day=6)
Example #38
0
def to_date(strDate):
    tmpDate = lambda dt: _date(int(dt[0]), int(dt[1]), int(dt[2]))
    return tmpDate(strDate.split('-'))
Example #39
0

# Version of Where.
#
# This is automatically set using the where_release tool
__version__ = "1.1.0"


# Authors of the software
_Author = _namedtuple("_Author", ["name", "email", "start", "end"])

_AUTHORS = [
    _Author("Michael Dähnn", "*****@*****.**", _date.min, _date.max),
    _Author("Ingrid Fausk", "*****@*****.**", _date.min, _date.max),
    _Author("Ann-Silje Kirkvik", "*****@*****.**", _date.min, _date.max),
    _Author("Mohammed Ouassou", "*****@*****.**", _date(2018, 9, 1), _date.max),
    # Hall of Fame
    _Author("Eirik Mysen", "*****@*****.**", _date.min, _date(2017, 6, 1)),
    _Author("Geir Arne Hjelle", "*****@*****.**", _date.min, _date(2019, 2, 1)),
]

__author__ = ", ".join(a.name for a in _AUTHORS if a.start < _date.today() < a.end)
__contact__ = ", ".join(a.email for a in _AUTHORS if a.start < _date.today() < a.end)


# Copyleft of the software
__copyright__ = "2015 - {} Kartverket".format(_date.today().year)


# Name of executable (on Windows/DOS, WHERE is a builtin command), add custom formatter to list subprograms
class Executable(str):
Example #40
0
 def __init__(self, y, m, d):
     self.limits, self.workindays = [1, 7], False
     BaseControl.__init__(self, startDate=_date(y, m, d))
Example #41
0
 def test_ist_kein_Feiertag(self):
     d = _date(2013, 5, 14)
     self.assertFalse(is_special_day(d))
Example #42
0
 def __init__(self, y, m, d):
     self.days_calc = lambda: [_fix_ctrlday(_date(y, m, d) + _timedelta(days=i)) for i in PostPromotional.days_ctrls]
     super(PostPromotional, self).__init__()
Example #43
0
 def __init__(self, y, m, d):
     self.limits = [3, 7, 20, 28]
     BaseControl.__init__(self, startDate=_date(y, m, d))
Example #44
0
 def test_ist_Wochenende(self):
     d = _date(2013, 5, 18)
     self.assertTrue(is_special_day(d, include_weekend=True))
Example #45
0
 def __init__(self, y, m, d):
     self.limits, self.workindays = [9, 15, 20, 25, 30, 35], False
     BaseControl.__init__(self, startDate=_date(y, m, d), Days=False)
Example #46
0
 def test_ist_Ostersonntag_1(self):
     d = _date(2014, 4, 20)
     self.assertEqual(d, easter_sunday(2014))
Example #47
0
def f_date(year, month, day):
    """
    Defines a date value
    """
    return _date(val_to_integer(year), val_to_integer(month),
                 val_to_integer(day))
Example #48
0
 def test_ist_Ostersonntag_2(self):
     d = _date(2020, 4, 12)
     self.assertEqual(d, easter_sunday(2020))