 # Extract specific time from the document pubdate field and compare it with the test
 matchesPubdate = (objectKey, pubdateTest, object) ->
   objectValue = object[objectKey]
-  year = new Date(objectValue * 1000).getFullYear() # convert to milliseconds
+  year = new Date(objectValue).getFullYear() # convert to milliseconds
 
   if 'year' of pubdateTest # compare years
     testValue = pubdateTest['year']

      else
        re = RegExp substring, "m" # multiline matching
      if objectValueStr
        match = objectValueStr.match re

      # if substring in object value str
      return true if match


# Check if specific field value is empty
isEmpty = (objectKey, emptyTest, object) ->
  if objectKey not of object
    # this field does not exist so return true that it's "empty"
    # TODO: throw an error
    return true

  objectValue = object[objectKey]
  objectValueIsCorrectType = (objectValue isnt null) and (typeof objectValue isnt 'boolean')
  shouldBeEmpty = emptyTest['empty']

  if shouldBeEmpty and objectValueIsCorrectType #return true if objectValue is empty
    return objectValue.length is 0

  else if not shouldBeEmpty and objectValueIsCorrectType #return true if objectValue is not empty
    return objectValue.length isnt 0

  else #objectValue is not correct type, so makes no sense to check if it's empty
    #TODO: throw an error
    return true



# Check if the test is a pubdate test
isPubdateTest = (testValues) ->
