VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Times"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit
Dim t As Single
Dim errflag As Boolean
Private Const tmNT = 10000, tmDQ = 20000, tmSCRATCH = 30000

'This class is used to read and format times
'it also holds definitive declarations of special constants
Property Get NT() As Single
  NT = tmNT
End Property

Property Get SCRATCH() As Single
  SCRATCH = tmSCRATCH
End Property

Property Get DQ() As Single
  DQ = tmDQ
End Property

Public Sub setSingle(tv As Single)
  t = tv
End Sub

Public Function getSingle()
  getSingle = t
End Function

Public Function getWFormatted(width As Integer) As String
  Dim s$, w As Integer
  s$ = getFormatted
  w = width - Len(s$)
  If w > 0 Then
    s$ = Space$(w) + s$
  End If
  getWFormatted = s$
End Function

Public Function getFormatted() As String
  Dim mins As Integer, secs As Single, s$
  If t >= 100 And t < 3000 Then
    mins = t \ 100
    secs = t - mins * 100
  Else
    secs = t
  End If
  If mins > 0 Then
    s$ = Trim$(Str$(mins)) + ":" + Format$(secs, "00.00")
    getFormatted = s$
  Else
    getFormatted = Format$(secs, "##.00")
  End If
  If t = NT Or t = 0 Then
    getFormatted = "NT"
  End If
  If t = DQ Then
    getFormatted = "DQ"
  End If
  If t = SCRATCH Then
    getFormatted = "SCR"
  End If
End Function

Public Function setText(ByVal tx As String) As Boolean
  Dim i As Integer, mins As Integer, secs As Single
  errflag = False

  tx = Trim$(tx)
  i = InStr(tx, ":")
  If i > 0 Then
    mins = Val(Left$(tx, i - 1))
    secs = Val(Right$(tx, Len(tx) - i))
    If secs > 59.99 Then
      errflag = True
    End If
    t = mins * 100 + secs
  Else
    mins = Val(tx) \ 100
    secs = Val(tx) - (100 * mins)
    If secs > 59.99 Then
      errflag = True
      t = NT
    Else
      t = Val(tx)
    End If
  End If
  If Left$((UCase$(tx)), 1) = "S" Then
    t = SCRATCH
  End If
  If UCase$(tx) = "NT" Or UCase(tx) = "N.T." Then
    t = NT
  End If
  setText = Not errflag   'true if OK, false if error
End Function

Public Function getSeconds(t As Single) As Single
  Dim mins As Integer, secs As Single

  mins = t \ 100
  secs = t - mins * 100
  getSeconds = mins * 60 + secs
End Function

Public Sub setSeconds(s As Single)
  Dim mins As Integer, secs As Single

  mins = s \ 60
  secs = s - mins * 60
  t = mins * 100 + secs
End Sub

Public Function getMinutes(t As Single) As Single
  Dim mins As Integer, secs As Single
  mins = t \ 60
  secs = t - mins * 60
  getMinutes = mins * 100 + secs
End Function

