<commit_before>const moment = require('moment-timezone')
const sherlock = require('../../other_modules/sherlock/sherlock')
const errors = require('./../errors')
const logger = require('winston')

const retrieveDateAndTitleFromSupplementaryText = data => {
  const rightNow = new Date()
  const nowLocalDate = convertDateToLiteralTimezoneEquivalent(rightNow, data.timezone, true)
  logger.log('debug', 'Server Now:', nowLocalDate)

  // Process Local Date as GMT to ensure "tomorrow" is tomorrow locally
  sherlock._setNow(nowLocalDate)
  var sherlocked = sherlock.parse(data.supplementaryText)

  if (sherlocked.startDate == null) {
    data.errorMessage = errors.errorTypes.noDateTime
    throw data
  } else {
    var startDateLocal = sherlocked.startDate
    logger.log('debug', 'sherlocked.startDate:', startDateLocal)
    var startDateGMT = convertDateToLiteralTimezoneEquivalent(startDateLocal, data.timezone, false)
    logger.log('debug', 'startDateGMT:', startDateGMT)
    var userDateText = timezonedDateText(startDateLocal)
    logger.log('debug', 'userDateText: ' + userDateText)
    logger.log('debug', 'sherlocked.eventTitle: ' + sherlocked.eventTitle)
    let title = sherlocked.eventTitle
    if (!title) {
      data.errorMessage = errors.errorTypes.noTitle
      throw data
    }
    if (title.substring(0, 3) === 'to ') {
      title = title.substring(3)
    }
    data.reminderWhenGMT = startDateGMT
    data.reminderUserDateText = userDateText
    data.reminderTitle = title.trim()
    return data
  }
}

const convertDateToLiteralTimezoneEquivalent = (date, timezoneText, reverse) => {<commit_msg>length check for removal of to<commit_after>const moment = require('moment-timezone')
const sherlock = require('../../other_modules/sherlock/sherlock')
const errors = require('./../errors')
const logger = require('winston')

const retrieveDateAndTitleFromSupplementaryText = data => {
  const rightNow = new Date()
  const nowLocalDate = convertDateToLiteralTimezoneEquivalent(rightNow, data.timezone, true)
  logger.log('debug', 'Server Now:', nowLocalDate)

  // Process Local Date as GMT to ensure "tomorrow" is tomorrow locally
  sherlock._setNow(nowLocalDate)
  var sherlocked = sherlock.parse(data.supplementaryText)

  if (sherlocked.startDate == null) {
    data.errorMessage = errors.errorTypes.noDateTime
    throw data
  } else {
    var startDateLocal = sherlocked.startDate
    logger.log('debug', 'sherlocked.startDate:', startDateLocal)
    var startDateGMT = convertDateToLiteralTimezoneEquivalent(startDateLocal, data.timezone, false)
    logger.log('debug', 'startDateGMT:', startDateGMT)
    var userDateText = timezonedDateText(startDateLocal)
    logger.log('debug', 'userDateText: ' + userDateText)
    logger.log('debug', 'sherlocked.eventTitle: ' + sherlocked.eventTitle)
    let title = sherlocked.eventTitle
    if (!title) {
      data.errorMessage = errors.errorTypes.noTitle
      throw data
    }
    if (title.length > 3 && title.substring(0, 3) === 'to ') {
      title = title.substring(3)
    }
    console.log(' ***** ' + title)
    data.reminderWhenGMT = startDateGMT
    data.reminderUserDateText = userDateText
    data.reminderTitle = title.trim()
    return data
  }
}

const convertDateToLiteralTimezoneEquivalent = (date, timezoneText, reverse) => {
{'fraction_non_alphanumeric': 0.1163141993957704, 'fraction_numerical': 0.0021148036253776435, 'mean_word_length': 4.383739837398374, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2404904', 'n_tokens_mistral': 1026, 'n_tokens_neox': 999, 'n_words': 213}