systemapic / systemapic.js

Systemapic Javascript API
https://systemapic.com
0 stars 3 forks source link

timeseries detection is buggy #24

Closed knutole closed 8 years ago

knutole commented 8 years ago

Need to improve how detecting timeseries for different types of data.

jorgenevil commented 8 years ago

Might be problematic:

Moment's validation functions are limited to validating whether a given date/time input string is valid according to a given format. It is assumed that the format(s) are known to the developer. It's not intended to accept the format string itself from a variable source such as the end user.

So no, there are no methods for confirming that the format string is valid.

function checkIfDateIsValidUsingMoment(dateString,format)
{
  var m=moment(dateString,format);
  return m._pf.charsLeftOver ==0 && m._pf.unusedTokens.length==0 && m._pf.unusedInput.length==0 && m.isValid();
}

Above function takes datestring and format, Moment object has isvalid method but its less usable for strict date validation.

Moment Object has _pf which stores info about parsed date. charsLeftOver: no of chars that do not match (Means extra character, invalid date) unusedInput: array containing details about unused inputs unusedTokens: array containing details about unused tokens

jorgenevil commented 8 years ago

Alternative libraries:

http://arshaw.com/xdate/ https://github.com/abritinthebay/datejs/

knutole commented 8 years ago

related to #29

knutole commented 8 years ago

fixed by a52ea9d