Sumar dias habiles / Working days

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
def suma_dias_habiles(fecha_origen, dias):
    h = dias
    ds = 5 - fecha_origen.weekday() # distancia al sabado
    s = 0
    if h >= ds: 
        s = s + 2
        h = h - ds
        
    s = s + h / 5 * 2
    return datetime.date.fromordinal( fecha_origen.toordinal() + dias + s )

More like this

  1. Calendar table by fauxparse 5 years ago
  2. SplitSelectDateTimeWidget by bradmontgomery 4 years, 6 months ago
  3. Client-side Django-style date & time string formatting by robbie 6 years, 2 months ago
  4. Fuzzy Time of Day by waylan 5 years, 11 months ago
  5. custom DateField format widget by Gandalfar 6 years, 2 months ago

Comments

(Forgotten your password?)