You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
817 B
JavaScript
54 lines
817 B
JavaScript
|
|
class SmartDateParseState
|
|
{
|
|
constructor()
|
|
{
|
|
this._value = '';
|
|
this._valueIndex = 0;
|
|
}
|
|
|
|
start(value)
|
|
{
|
|
this._value = value;
|
|
this._valueIndex = 0;
|
|
}
|
|
|
|
current()
|
|
{
|
|
return this.isOver() ? '' : this._value[this._valueIndex];
|
|
}
|
|
|
|
next()
|
|
{
|
|
if (this.isOver()) {
|
|
return false;
|
|
}
|
|
|
|
this._valueIndex++;
|
|
|
|
return !this.isOver();
|
|
}
|
|
|
|
isOver()
|
|
{
|
|
return this._valueIndex >= this._value.length;
|
|
}
|
|
|
|
value()
|
|
{
|
|
return this._value;
|
|
}
|
|
|
|
valueIndex()
|
|
{
|
|
return this._valueIndex;
|
|
}
|
|
|
|
setValueIndex(index)
|
|
{
|
|
if (this._valueIndex < index) {
|
|
this._valueIndex = index;
|
|
}
|
|
}
|
|
}
|