Exemple #1
0
    def on_date_button_pressed(self):
        simple_date = datetimeutil.str_date_simplify(self.date_edit.text(), self.info.date_format)
        fixed_date = datetimeutil.fix_date_format(simple_date, self.info.date_format)

        dialog = DateDialog(fixed_date, self)
        dialog.update.connect(self.date_updated)
        dialog.exec_()
    def on_date_button_pressed(self):
        simple_date = datetimeutil.str_date_simplify(self.date_edit.text(),
                                                     self.info.date_format_num)
        fixed_date = datetimeutil.fix_date_format(simple_date,
                                                  self.info.date_format_num)

        dialog = DateDialog(fixed_date, self)
        dialog.update.connect(self.date_updated)
        dialog.exec_()
    def reminder(self, label, time, date, command, notes, popup, dialog, boxcar, play,
                sound_file, sound_length, sound_loop, pushbullet_device, delete_id, check_warning = False):
        time = datetimeutil.str_time_simplify(time)
        if time == None:
            return (self.time_error, -1)

        date = datetimeutil.str_date_simplify(date, self.settings.date_format)
        if date == None:
            return (self.date_error, -1)

        if play:
            if sound_file == None:
                return (self.file_error, -1)
            else:
                try:
                    with open(sound_file) as f: pass
                except IOError as e:
                    return (self.file_error, -1)

        if label == "" and notes == "" and check_warning and (boxcar or popup or dialog or pushbullet_device):
            return (self.notify_warn, -1)

        if not play:
            sound_file = ""
        if sound_loop:
            sound_length = 0

        r = db.Alarm(-1)
        r.set_data(label, notes, time, date, sound_file, sound_length, sound_loop,
                popup, command, boxcar, dialog, pushbullet_device)

        self.database = db.Database(self.filename)
        id = self.database.insert_alarm(r)

        if delete_id != -1:
            self.database.delete_alarm(delete_id)

        self.database.close()

        if self.pushbullet_devices_updated:
            self.settings.dump()

        return (self.ok, id)
    "every weekday",
    "every weekday from monday",
    "every weekday from monday to next monday",
    "every weekend",
    "every weekend from sun",
    "every weekend from Oct 8, 2012 to October 8, 2013",
    "every other",
    "every other from 5",
    "every other from 5 to 10",
    "next 30 days",
    "next 30 days from yesterday",
    ]

counter = 0
for row in singular:
    value = d.str_date_simplify(row, 0)
    print str(value) + " (" + row + ")"
    dt = d.str_to_date(None, value)
    print dt

    if dt != valid_singular[counter]:
        print "should be " + str(valid_singular[counter])
        exit()

    counter += 1

counter = 0
for row in repeating:
    value = d.str_date_simplify(row, 0)
    print str(value) + " (" + row + ")"
    dt = d.str_to_date(None, value)
def valid_date(date_s, date_format):
    return datetimeutil.str_date_simplify(date_s, date_format) != None