Skip to content

Instantly share code, notes, and snippets.

@marcelcaraciolo
Created March 1, 2012 21:41
Show Gist options
  • Select an option

  • Save marcelcaraciolo/1953431 to your computer and use it in GitHub Desktop.

Select an option

Save marcelcaraciolo/1953431 to your computer and use it in GitHub Desktop.
dt.py
# -*- coding: utf-8 -*-
import datetime as dt_variation
from datetime import datetime
DELTA = dt_variation.timedelta(days=2)
DATAS = ['2012-02-08', '2012-02-09', '2012-02-10', '2012-02-11', '2012-02-12']
PONTO_MOVIMENTO = ''
def gera_data(datas, variation):
delta = dt_variation.timedelta(days=variation)
datas = map(lambda i: datetime.strptime(i, "%Y-%m-%d").isoweekday(), datas)
PONTO_MOVIMENTO = DATAS[datas.index(6)]
for dt in DATAS:
if datetime.strptime(dt, "%Y-%m-%d") >= datetime.strptime(PONTO_MOVIMENTO, "%Y-%m-%d"):
print "Incrementa 2 dias e grava no banco: " + str(datetime.strptime(dt, "%Y-%m-%d") + delta)
else:
print "Não incrementa e grava no banco: " + str(datetime.strptime(dt, "%Y-%m-%d"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment