# Path: wh.py
# def prettyDate(val, long=True):
#   if isinstance(val, datetime.datetime):
#     val=val.timetuple()
#   if not isinstance(val, time.struct_time):
#     val=time.localtime(val)
#   if long:
#     return time.strftime("%Y-%m-%d %H:%M:%S", val)
#   else:
#     return time.strftime("%Y-%m-%d", val)


import wx
import time
from wh import prettyDate
  def IsValid(self):
    return len(self.ctl.GetValue() == self.len)

  def GetValue(self):
    v=self.ctl.GetValue()
    if len(v) == self.len:
      return v.lower().replace('.', ':').replace('-', ':')
    return None

  def OnChar(self, ev):
    keycode = int(ev.GetKeyCode())

    if keycode < 256 and keycode >31:
      if self.ctl.GetInsertionPoint() == 17:
        return
      if len(self.ctl.GetValue()) == 17:
        a,e=self.ctl.GetSelection()
        if a == e:
          return
      if self.ctl.GetInsertionPoint() in (2,5,8,11,14):
        if not chr(keycode) in ".-:":
          return
      else:
        if not chr(keycode) in self.chars:
          return

    ev.Skip()


class TimestampValidator(Validator):

# Path: wh.py
# def prettyDate(val, long=True):
#   if isinstance(val, datetime.datetime):
#     val=val.timetuple()
#   if not isinstance(val, time.struct_time):
#     val=time.localtime(val)
#   if long:
#     return time.strftime("%Y-%m-%d %H:%M:%S", val)
#   else:
#     return time.strftime("%Y-%m-%d", val)


# Path: Validator.py
import wx
import time
from wh import prettyDate

  def IsValid(self):
    return len(self.ctl.GetValue() == self.len)

  def GetValue(self):
    v=self.ctl.GetValue()
    if len(v) == self.len:
      return v.lower().replace('.', ':').replace('-', ':')
    return None

  def OnChar(self, ev):
    keycode = int(ev.GetKeyCode())

    if keycode < 256 and keycode >31:
      if self.ctl.GetInsertionPoint() == 17:
        return
      if len(self.ctl.GetValue()) == 17:
        a,e=self.ctl.GetSelection()
        if a == e:
          return
      if self.ctl.GetInsertionPoint() in (2,5,8,11,14):
        if not chr(keycode) in ".-:":
          return
      else:
        if not chr(keycode) in self.chars:
          return

    ev.Skip()


class TimestampValidator(Validator):

  def __init__(self, ctl, unused_params):