old_contents: from datetime import datetime as dt
  import os
  
  
  LOG_FILE = os.path.expanduser('~') + '/.timelog/timeflow'
  DATETIME_FORMAT = "%Y-%m-%d %H:%M"
  DATE_FORMAT = "%Y-%m-%d"
  DATE_LEN = 10
  
  
  def write_to_log_file(message):
      log_message = form_log_message(message)
      if not os.path.exists(os.path.dirname(LOG_FILE)):
          os.makedirs(os.path.dirname(LOG_FILE))
      with open(LOG_FILE, 'a') as fp:
          fp.write(log_message)
  
  
  def read_log_file_lines():
      with open(LOG_FILE, 'r') as fp:
          return [line for line in fp.readlines() if line != '\n']
  
  
  def form_log_message(message):
      time_str = dt.now().strftime(DATETIME_FORMAT)
      log_message = ': '.join((time_str, message))
      if is_another_day():
          return '\n' + log_message + '\n'
      else:
          return log_message + '\n'
  
  
  def is_another_day():
      """
      Checks if new message is written in the next day,
      than the last log entry.
  
      date - message date
      """
      try:
          f = open(LOG_FILE, 'r')
          last_line = f.readlines()[-1]
      except (IOError, IndexError):
          return False
  
      last_log_date = last_line[:DATE_LEN]
  
      # if message date is other day than last log entry
      if dt.now().strftime(DATE_FORMAT) != last_log_date:
          return True
      else:
          return False
  
new_contents: from datetime import datetime as dt
  import os
  
  
  LOG_FILE = os.path.expanduser('~') + '/.timelog/timeflow'
  DATETIME_FORMAT = "%Y-%m-%d %H:%M"
  DATE_FORMAT = "%Y-%m-%d"
  # length of date string
  DATE_LEN = 10
  # length of datetime string
  DATETIME_LEN = 16
  
  
  def write_to_log_file(message):
      log_message = form_log_message(message)
      if not os.path.exists(os.path.dirname(LOG_FILE)):
          os.makedirs(os.path.dirname(LOG_FILE))
      with open(LOG_FILE, 'a') as fp:
          fp.write(log_message)
  
  
  def read_log_file_lines():
      with open(LOG_FILE, 'r') as fp:
          return [line for line in fp.readlines() if line != '\n']
  
  
  def form_log_message(message):
      time_str = dt.now().strftime(DATETIME_FORMAT)
      log_message = ': '.join((time_str, message))
      if is_another_day():
          return '\n' + log_message + '\n'
      else:
          return log_message + '\n'
  
  
  def is_another_day():
      """
      Checks if new message is written in the next day,
      than the last log entry.
  
      date - message date
      """
      try:
          f = open(LOG_FILE, 'r')
          last_line = f.readlines()[-1]
      except (IOError, IndexError):
          return False
  
      last_log_date = last_line[:DATE_LEN]
  
      # if message date is other day than last log entry
      if dt.now().strftime(DATE_FORMAT) != last_log_date:
          return True
      else:
          return False
  
subject: Add datetime string length constant