title: Python date over start increase
body: <p>Problem about date from file, how can I increase date by one day with given start from file.</p>
  
  <p>My file looks like:</p>
  
  <pre><code>13.12.2013.   
  
  06:00 ZMBT televoting
  06:05 Madhubala, igrana serija, 138. epizoda, r.
  06:50 Tajne, igrana serija, 55. epizoda, r.
  07:30 Naša kuhinja
  08:25 TV izlog
  08:45 Bratzillaz, crtani film, 7. i 8. epizoda
  08:55 ZMBT televoting
  09:00 Prva dama, igrana serija, 89. epizoda
  10:00 Štrumfovi, crtani film, 20. epizoda
  10:30 Pčelica Maja, crtani film, 5. epizoda
  10:52 Monster high, crtani film, 404. i 405. epizoda 
  10:55 Monsuno, crtani film, 20. epizoda
  11:20 TV izlog 
  11:40 Tokovi novca
  11:45 Vijesti           
  11:57 Biometeorološka prognoza
  12:00 Madhubala, igrana serija, 138. epizoda, r.
  12:50 Prva dama, igrana serija, 90. epizoda 
  13:50 Tajne, igrana serija, 55. epizoda
  14:40 TV izlog
  15:15 ZMBT televoting 
  15:20 Muzički program
  15:45 ZMBT televoting 
  15:50 Karadayi, igrana serija, 68. epizoda 
  16:50 Po spisku, talk show
  17:45 Krv nije voda, serijski program, 107. epizoda
  18:39 International Health
  18:49 Domaćica Ovako
  19:00 Vijesti u 7, informativni program
  19:28 Vremenska prognoza
  19:29 Biometeorološka prognoza
  19:31 Sport
  19:38 Stanje na putevima 
  19:45 Tokovi novca
  19:55 ZMBT televoting
  20:00 Kolo sreće
  20:05 Madhubala, igrana serija, 139. epizoda
  21:05 ZMBT 6, show uživo
  23:55 Sport centar
  00:00 Dolina vukova, igrana serija, 97. i 98. epizoda   
  Reprizni program Hayat TV-a    
  01:55 ZMBT televoting
  02:00 Vijesti u 7, informativni program
  02:30 ZMBT 6, show
  04:45 Muzički program
  
  14.12.2013. 
  
  06:00 ZMBT televoting
  06:05 Madhubala, igrana serija, 139. epizoda, r.
  06:50 Takešijev dvorac, zabavno-sportski TV show  
  </code></pre>
  
  <p>Problem is when date is in same day when midnight has pass, how can I make when 00:00 pass in day to get next date from file.
  My example of code:</p>
  
  <pre><code>#!/usr/bin/python
  # -*- coding: utf-8 -*-
  
  import os
  import sys
  import re
  import time 
  import glob
  import logging
  from datetime import datetime
  import datetime
  
  
  def get_date_time():
  
      # Values for date 
      # Example         : '''YYYY-MM-DD, YYYY-DD-MM, DD MM YYYY, MM DD YYYY'''
      # Example of time : '''(00:00:00, 00:00, 0:00 -- 24 Time) | (00:00, 0:00 -- AM, PM)'''
      ######################################################################################
      #Let's add some date/time examples
  
      ######################################################################################
      # TS -&gt; 05h 
      # Calculating time 
      # Open File for checking
      input_file = open('date.txt','r')
  
      # Open Output file for writting
      output     = open('date_change.txt','w')
  
      for line in input_file:
          # Let's take date with regex on example --&gt; 1/6/2014 (MM-DD-YYYY), Time --&gt; 24h (0:00| 00:00)
  
          if re.search(r'\d{2}.\d{2}.\d{4}', line):
  
              line_date1  = re.findall(r'\d{2}.\d{2}.\d{4}',line)[0]
  
          else:
  
              if not re.search(r'\d{2}.\d{2}.\d{4}',line):
                  line_date = ''
                  print line_date
                  # Start
  
          if re.search(r'\d{2}:\d{2}.*',line):
              line_start = re.findall(r'\d{2}:\d{2}',line)[0]
              var2 = line_start+' '+line_date1
  
              var = line_start
  
              if var &gt; '00:00':
  
                  var1 = var
                  Date = datetime.datetime.strptime(line_date1, "%d.%m.%Y")
                  EndDate = Date + datetime.timedelta(days=1)
                  print str(EndDate) + ' '+var1
  
              else:
                  Date = datetime.datetime.strptime(line_date1, "%d.%m.%Y")
  
                  print str(Date)+' '+var1
  
  get_date_time()
  </code></pre>
  
  <p>If you could give me some help about this problem.</p>
  
  <p>Output would be like this:</p>
  
  <pre><code>13.12.2013. 06:00 ZMBT televoting
  13.12.2013. 06:05 Madhubala, igrana serija, 138. epizoda, r.
  13.12.2013. 06:50 Tajne, igrana serija, 55. epizoda, r.
  13.12.2013. 07:30 Naša kuhinja
  13.12.2013. 08:25 TV izlog
  13.12.2013. 20:05 Madhubala, igrana serija, 139. epizoda
  13.12.2013. 21:05 ZMBT 6, show uživo
  13.12.2013. 23:55 Sport centar
  
  14.12.2013. 00:00 Dolina vukova, igrana serija, 97. i 98. epizoda      
  14.12.2013. 01:55 ZMBT televoting
  14.12.2013. 02:00 Vijesti u 7, informativni program
  14.12.2013. 02:30 ZMBT 6, show
  14.12.2013. 04:45 Muzički program
  </code></pre>
  
  <p>Here is my result, i mean code it works i just add some lines. Guys thx for help. here is my code if anybody need's help:</p>
  
  <pre><code>def get_date_time():
  
      # Values for date 
      # Example         : '''YYYY-MM-DD, YYYY-DD-MM, DD MM YYYY, MM DD YYYY'''
      # Example of time : '''(00:00:00, 00:00, 0:00 -- 24 Time) | (00:00, 0:00 -- AM, PM)'''
      ######################################################################################
      #Let's add some date/time examples
  
      ######################################################################################
      # TS -&gt; 05h 
      # Calculating time 
      # Open File for checking
      input_file = open('date.txt','r')
  
      # Open Output file for writting
      output     = open('date_change.txt','w')
      date = ""
      var  = ""
  
      for line in input_file:
          # Let's take date with regex on example --&gt; 1/6/2014 (MM-DD-YYYY), Time --&gt; 24h (0:00| 00:00)
          if re.search(r'\d{2}.\d{2}.\d{4}.',line):
              line_date = re.findall(r'\d{2}.\d{2}.\d{4}.',line)[0]
              date = line_date
              x    = date
  
              print date
  
          if re.search(r'\d{2}:\d{2}.*', line):
              line_start = re.findall(r'\d{2}:\d{2}', line)[0]
              line_title = re.findall(r'\s\w*',line)[0]
              global var_x
              var_x     = var + line_start
              var2 = line_title
  
  
              current_date = datetime.datetime.strptime(x, '%d.%m.%Y.')
              new_date     = current_date + datetime.timedelta(days=1)
  
  
              if var_x &lt; '06:00':
                  var1 = var_x
  
                  print &gt;&gt; output, str(new_date)+' '+var1+' '+var2+'\n'
              else:
                  print &gt;&gt; output, str(current_date)+' '+var_x+' '+var2+'\n'
  
  
  
  
  
  
  get_date_time()
  </code></pre>