# Module: Tgio::Dates

# Public Class Methods

### inputdate ()

Inputs a date

Show source...

         # File bbs/lib/tgio/dates.rb, line 163
    163: def Dates::inputdate
    164:   trap("INT") do
    165:     # ignore "CTRL-C"
    166:   end
    167:   tr = JLine::ConsoleReader.new
    168:   char = nil
    169:   enterkey = false
    170:   input = []
    171:   cursize = 0
    172:   print ANSI_RESET+(ANSI_BRIGHT_WHITE+ANSI_ON_BLUE+"MM/DD/YYYY")
    173:   print "\b" * 10
    174:   month = self.inputmonth
    175:   print ANSI_BRIGHT_WHITE+ANSI_ON_BLUE+"/"
    176:   day   = self.inputday
    177:   print ANSI_BRIGHT_WHITE+ANSI_ON_BLUE+"/"
    178:   year  = self.inputyear
    179:   print ANSI_RESET
    180:   print "\n"
    181:   value = Date.parse("#{year}-#{month}-#{day}")
    182:   return value
    183: end

### inputday ()

Input a day

Show source...

         # File bbs/lib/tgio/dates.rb, line 124
    124: def Dates::inputday
    125:   tr = JLine::ConsoleReader.new
    126:   char = nil
    127:   enterkey = false
    128:   input = []
    129:   cursize = 0
    130:   maxsize = 2
    131:   vals1 = (48..51) # Month first digit is either 0 or 1
    132:   vals2 = (48..57) # Month second digit is 0 thru 9
    133:   print ANSI_RESET+(ANSI_BRIGHT_WHITE+ANSI_ON_BLUE+"MM")
    134:   print "\b" * 2
    135:   # TODO - Ensure val2 does not exceed 2 if val1 = 1
    136:   until cursize == maxsize
    137:     char = tr.readVirtualKey
    138:     case cursize
    139:       when 0
    140:         if vals1.include?(char)
    141:           input.push(char.chr)
    142:           cursize +=1
    143:           print ANSI_BRIGHT_WHITE+ANSI_ON_BLUE+char.chr
    144:         end #/if
    145:       when 1
    146:         if vals2.include?(char)
    147:           input.push(char.chr)
    148:           cursize +=1
    149:           print ANSI_BRIGHT_WHITE+ANSI_ON_BLUE+char.chr
    150:         end #/if
    151:     end
    152:   end #/until
    153:   print ANSI_RESET
    154:   value = ""
    155:   input.each do |c|
    156:     value.concat(c)
    157:   end
    158:   return value
    159: end

### inputmonth ()

Input a month

Show source...

         # File bbs/lib/tgio/dates.rb, line 86
     86: def Dates::inputmonth
     87:   tr = JLine::ConsoleReader.new
     88:   char = nil
     89:   enterkey = false
     90:   input = []
     91:   cursize = 0
     92:   maxsize = 2
     93:   vals1 = (48..49) # Month first digit is either 0 or 1
     94:   vals2 = (48..57) # Month second digit is 0 thru 9
     95:   print ANSI_RESET+(ANSI_BRIGHT_WHITE+ANSI_ON_BLUE+"MM")
     96:   print "\b" * 2
     97:   # TODO - Ensure val2 does not exceed 2 if val1 = 1
     98:   until cursize == maxsize
     99:     char = tr.readVirtualKey
    100:     case cursize
    101:       when 0
    102:         if vals1.include?(char)
    103:           input.push(char.chr)
    104:           cursize +=1
    105:           print ANSI_BRIGHT_WHITE+ANSI_ON_BLUE+char.chr
    106:         end #/if
    107:       when 1
    108:         if vals2.include?(char)
    109:           input.push(char.chr)
    110:           cursize +=1
    111:           print ANSI_BRIGHT_WHITE+ANSI_ON_BLUE+char.chr
    112:         end #/if
    113:     end
    114:   end #/until
    115:   print ANSI_RESET
    116:   value = ""
    117:   input.each do |c|
    118:     value.concat(c)
    119:   end
    120:   return value
    121: end

### inputyear ()

Input a year

Show source...

        # File bbs/lib/tgio/dates.rb, line 57
    57: def Dates::inputyear
    58:   tr = JLine::ConsoleReader.new
    59:   char = nil
    60:   enterkey = false
    61:   input = []
    62:   cursize = 0
    63:   maxsize = 4
    64:   vals = (48..57)
    65:   print ANSI_RESET+(ANSI_BRIGHT_WHITE+ANSI_ON_BLUE+"YYYY")
    66:   print "\b" * 4
    67:   until cursize == maxsize
    68:     char = tr.readVirtualKey
    69:     if vals.include?(char)
    70:       input.push(char.chr)
    71:       print ANSI_BRIGHT_WHITE+ANSI_ON_BLUE+char.chr
    72:       cursize +=1
    73:     else
    74:       print "\b"+ANSI_BRIGHT_WHITE+ANSI_ON_BLUE+" \b"
    75:     end #/if
    76:   end #/until
    77:   print ANSI_RESET
    78:   value = ""
    79:   input.each do |c|
    80:     value.concat(c)
    81:   end
    82:   return value
    83: end