How to use the datetime.date.today function in DateTime

To help you get started, we’ve selected a few DateTime examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cosmicpython / code / tests / unit / test_batches.py View on Github external
def make_batch_and_line(sku, batch_qty, line_qty):
    return (
        Batch("batch-001", sku, batch_qty, eta=date.today()),
        OrderLine("order-123", sku, line_qty)
    )
github Nekmo / telegram-upload / docs / conf.py View on Github external
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix of source filenames.
source_suffix = '.rst'

# The encoding of source files.
#source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = u'Telegram Upload'
copyright = u"%i, Nekmo Com" % datetime.date.today().year

pdf_documents = [('index', u'rst2pdf', u'Telegram Upload', u'Nekmo'), ]

rinoh_documents = [('index',            # top-level file (index.rst)
                    'target',           # output (target.pdf)
                    'Telegram Upload',   # document title
                    'Nekmo')]   # document author
# rinoh_logo = '_static/logo.png'
rinoh_domain_indices = False

html_context = dict(docs_scope='external')

# The version info for the project you're documenting, acts as replacement
# for |version| and |release|, also used in various other places throughout
# the built documents.
#
github thomst / logscan / src / timeparse.py View on Github external
def string_to_date(self, string):
        """Convert a string to a date-object.
        """
        today = datetime.date.today()
        date = two.findall(one.sub('0\g<0>', string))
        lenght = len(date)
        if lenght == 4: date = date[:2] + [''.join(date[2:])]
        elif lenght == 3: date[2] = (str(today.year)[:2] + date[2])
        elif lenght == 2: date.append(today.year)
        elif lenght == 1: date = date + [today.month, today.year]
        date = [int(x) for x in date]
        date.reverse()
        try: date = datetime.date(*date)
        except: raise ArgumentError(
            self,
            "couldn't parse '{0}' as date".format(string)
        )
        return date
github lincolnloop / salmon / docs / conf.py View on Github external
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix of source filenames.
source_suffix = '.rst'

# The encoding of source files.
#source_encoding = 'utf-8'

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = u'salmon'
copyright = u'%d, myauthor' % datetime.date.today().year

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '1.0'
# The full version, including alpha/beta/rc tags.
release = '1.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
github ChainsAutomation / chains / lib / chains / services / ical / __init__.py View on Github external
return False
            return tdiff
        elif(dateobj.__class__ == datetime.date):
            #print 'datetime.date'
            # If event is an all day event, the event starts at 8:00 :)
            t = datetime.time(8, 0, 0)
            fulldate = datetime.datetime.combine(dateobj, t)
            # remove tzinfo, make naive, we expect same time zone.
            tdiff = fulldate.replace(tzinfo=None) - now
            if(tdiff.days < 0):
                return False
            return tdiff
        elif(dateobj.__class__ == unicode):
            #print "unicode string: ",
            #print dateobj
            today = datetime.date.today()
            t = datetime.time(8, 0, 0)
            defaultdate = datetime.datetime.combine(today, t)
            try:
                # dateutil.parse
                parseddate = parse(dateobj, ignoretz=True, default=defaultdate)
            except ValueError:
                #print "parse failed"
                return False
            print parseddate

        else:
            print "unknown date format: ",
            print type(dateobj)
            print dateobj.__class__
            return False
github pybites / 100DaysOfCode / 009 / newpost.py View on Github external
def get_age():
    today = date.today()
    return (today - PYB_START).days
github quay / quay / initdb.py View on Github external
model.permission.add_prototype_permission(
        org, "read", activating_user=new_user_1, delegate_user=new_user_2
    )
    model.permission.add_prototype_permission(
        org, "read", activating_user=new_user_1, delegate_team=reader_team
    )
    model.permission.add_prototype_permission(
        org, "write", activating_user=new_user_2, delegate_user=new_user_1
    )

    today = datetime.today()
    week_ago = today - timedelta(6)
    six_ago = today - timedelta(5)
    four_ago = today - timedelta(4)
    yesterday = datetime.combine(date.today(), datetime.min.time()) - timedelta(hours=6)

    __generate_service_key(
        "kid1", "somesamplekey", new_user_1, today, ServiceKeyApprovalType.SUPERUSER
    )
    __generate_service_key(
        "kid2",
        "someexpiringkey",
        new_user_1,
        week_ago,
        ServiceKeyApprovalType.SUPERUSER,
        today + timedelta(days=14),
    )

    __generate_service_key("kid3", "unapprovedkey", new_user_1, today, None)

    __generate_service_key(
github JYamihud / blender-organizer / orginizer.py View on Github external
exec (command) in globals(), locals()
        #print command
    
    # READING FILE
    
    if curfile != " ":
        checkfile = tuple(open(os.getcwd()+"/dev/"+cfplease+"/"+curfile+"/asset.progress", "r"))
    else:
        checkfile = tuple(open("project.progress", "r"))
    # DATES
    # format to use DAY/MONTH/YEAR
    
    DATESBOX = gtk.HBox(False, 5)
    checkbox.pack_start(DATESBOX)
    
    rawToday = datetime.date.today()
    print rawToday
    
    
    today = gtk.Label("⌚ Now: "+str(rawToday)[-2:]+"/"+str(rawToday)[5:7]+"/"+str(rawToday)[:4]+" Start:")
    DATESBOX.pack_start(today)
    
    
    global startdate
    startdate = gtk.Entry()
    for i in checkfile:
        if i[:4] == "STR ":
            startdate.set_text(i[4:][:-1])
    if startdate.get_text() == "00/00/0000":
        startdate.set_text(str(rawToday)[-2:]+"/"+str(rawToday)[5:7]+"/"+str(rawToday)[:4])
    DATESBOX.pack_start(startdate)
    startdate.connect("activate", checkListOperations, "date", True)
github cubaneorg / cubane / ishop / basket.py View on Github external
def set_voucher(self, voucher_code, restore_from_order_or_frozen=False):
        """
        Set the given voucher code for this basket. Returns True, if the voucher
        code is valid and has been applied to this basket successfully.
        """
        today = datetime.date.today()

        try:
            # find matching voucher, enabled and within valid time interval
            if restore_from_order_or_frozen:
                voucher = Voucher.objects.get(
                    enabled=True,
                    code__iexact=voucher_code
                )
            else:
                voucher = Voucher.objects.get(
                    self._match_voucher_time_interval(today),
                    enabled=True,
                    code__iexact=voucher_code
                )

            # test if voucher is available (usage)
github dryan / d3ploy / docs / conf.py View on Github external
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix of source filenames.
source_suffix = '.rst'

# The encoding of source files.
#source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = u'd3ploy'
copyright = u', '.join([ '-'.join(list(set([u'2013', date.today().strftime('%Y')]))), 'dryan'])

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '2.0.7'
# The full version, including alpha/beta/rc tags.
release = version

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used: