====Params
 * <tt>options</tt> - Accepts the following options
 ** :type - 'Marriage', etc. REQUIRED
 ** :date - 'Utah, United States' (optional)
 ** :place - '16 Nov 1987' (optional)
7164
def add_event(options)
      self.events ||= []
      event = EventAssertion.new
      event.add_value(options)
      self.events << event
    end
335312
function getDate (type, min, max, format, options) {
  var ret;

  // Juggle the arguments if the user didn't supply a format string
  if (!options) {
    options = format;
    format = null;
  }

  if (type === 'date') {
    min = Date.parse(min);
    max = Date.parse(max);
  } else if (type === 'time') {
    min = Date.parse('1970-01-01T' + min);
    max = Date.parse('1970-01-01T' + max);
  }

  ret = utils.randomDate(min, max);

  if (format === 'unix') {
    // We need to undo the timezone offset fix from utils.randomDate()
    ret = Math.floor((ret.getTime() - ret.getTimezoneOffset() * 60000) / 1000);
  } else if (format) {
    ret = fecha.format(ret, format);
  } else if (type === 'time') {
    // Time has a default format if one is not specified
    ret = fecha.format(ret, 'HH:mm');
  }

  return ret;
}
215996
def process_date_from_to_options(options, to_datetime=False, default_dt_to=False):
    
    start_time = datetime.datetime.now()

    if options.get('last_week'):
        dt_from = start_time - datetime.timedelta(days=7)
        dt_to = start_time

    elif options.get('last_day'):
        dt_from = start_time - datetime.timedelta(days=1)
        dt_to = start_time

    elif options.get('last_2hours'):
        dt_from = start_time - datetime.timedelta(hours=2)
        dt_to = start_time

    else:
        from_str = options.get('from')
        if from_str:
            try:
                dt_from = iso_to_datetime(from_str)
            except:
                dt_from = iso_to_date(from_str)
        else:
            dt_from = None

        to_str = options.get('to')
        if to_str:
            try:
                dt_to = iso_to_datetime(to_str)
            except:
                dt_to = iso_to_date(to_str)
        else:
            dt_to = None

    if default_dt_to and not dt_to:
        dt_to = datetime.datetime(2100, 1, 1)

    if to_datetime:
        if isinstance(dt_from, datetime.date):
            dt_from = date_to_datetime(dt_from)
        if isinstance(dt_to, datetime.date):
            dt_to = date_to_datetime_lte(dt_to)

    return dt_from, dt_to
442597
function(a, b) {
            c = this;
            if (!b) {
                return c.options[a];
            } else {
                c._u(a, b);
            }
        }
413334
def options(self, options=None):
		

		# If opts aren't set, this is a getter
		if options is None:
			return self._options

		# If the options are not a list
		if not isinstance(options, (list, tuple)):
			raise ValueError('__options__')

		# If the type is not one that can have options
		if self._type not in ['base64', 'date', 'datetime', 'decimal', 'float', \
								'int', 'ip', 'md5', 'price', 'string', 'time', \
								'timestamp', 'uint', 'uuid']:
			raise TypeError('can not set __options__ for ' + self._type)

		# Init the list of options to be saved
		lOpts = []

		# Go through each item and make sure it's unique and valid
		for i in range(len(options)):

			# Convert the value based on the type
			# If the type is a string one that we can validate
			if self._type in ['base64', 'date', 'datetime', 'ip', 'md5', 'time', 'uuid']:

				# If the value is not a string or doesn't match its regex, raise
				# 	an error
				if not isinstance(options[i], basestring) \
					or not _typeToRegex[self._type].match(options[i]):
					raise ValueError('__options__[%d]' % i)

			# Else if it's decimal
			elif self._type == 'decimal':

				# If it's a Decimal
				if isinstance(options[i], Decimal):
					pass

				# Else if we can't conver it
				else:
					try: options[i] = Decimal(options[i])
					except ValueError:
						raise ValueError('__options__[%d]' % i)

			# Else if it's a float
			elif self._type == 'float':

				try:
					options[i] = float(options[i])
				except ValueError:
					raise ValueError('__options__[%d]' % i)

			# Else if it's an integer
			elif self._type in ['int', 'timestamp', 'uint']:

				# If we don't already have an int
				if not isinstance(options[i], (int, long)):

					# And we don't have a string
					if not isinstance(options[i], basestring):
						raise ValueError('__options__[%d]' % i)

					try:
						options[i] = int(options[i], 0)
					except ValueError:
						raise ValueError('__options__[%d]' % i)

				# If the type is unsigned and negative, raise an error
				if self._type in ['timestamp', 'uint'] and options[i] < 0:
					raise ValueError('__options__[' + str(i) + ']')

			# Else if it's a price
			elif self._type == 'price':

				# If it's a Decimal
				if isinstance(options[i], Decimal):
					pass

				# Else if it's not a valid price representation
				elif not isinstance(options[i], basestring) or not _typeToRegex['price'].match(options[i]):
					raise ValueError('__options__[%d]' % i)

				# Store it as a Decimal
				options[i] = Decimal(options[i])

			# Else if the type is a string
			elif self._type == 'string':

				# If the value is not a string
				if not isinstance(options[i], basestring):

					# If the value can't be turned into a string
					try:
						options[i] = str(options[i])
					except ValueError:
						raise ValueError('__options__[%d]' % i)

			# Else we have no validation for the type
			else:
				raise TypeError('can not set __options__ for ' + self._type)

			# If it's already in the list, raise an error
			if options[i] in lOpts:
				sys.stderr.write('__options__[' + str(i) + '] is a duplicate')

			# Store the option
			else:
				lOpts.append(options[i])

		# Store the list of options
		self._options = lOpts
461795
function TransactionDate (dateString, format, options) {
  options = options || {}
  var parsed = parseDate(dateString, format)

  this.year = parsed.year
  this.month = parsed.month
  this.date = parsed.date

  if (!this.year && options.succeedingDate) {
    this.year = this.calculateYear(options.succeedingDate)
  }
}
1352367
private Date readOptionalDate(JSONValue val) {

        JSONString str = null == val ? null : val.isString();
        if (str != null) {
            try {
                return new Date(Long.parseLong(str.stringValue()));
            } catch (@SuppressWarnings("unused") NumberFormatException e) {
                // do nothing - return the default value
            }
        }
        return null;
    }
703946
function parseFindOptions(model, options, expectSingleResult) {
    var select, where, params, append, limit, offset;
    if (options.select) {
        if (Array.isArray(options.select)) {
            select = _.map(options.select, function (f) {
                return '`' + f + '`';
            }).join(', ');
        } else {
            select = options.select;
        }
    } else {
        select = model.__selectAttributesNames;
    }

    where = options.where || '';
    params = options.params || [];
    append = '';

    if (options.order) {
        append = append + ' order by ' + options.order;
    }
    limit = options.limit;
    offset = options.offset;

    if (limit === undefined && expectSingleResult) {
        limit = 2;
    }

    if (limit && offset) {
        append = append + ' limit ' + offset + ',' + limit;
    } else {
        if (limit) {
            append = append + ' limit ' + limit;
        }
        if (offset) {
            append = append + ' limit ' + offset + ',2147483647';
        }
    }
    return {
        select: select,
        where: where,
        params: params,
        append: append
    };
}
1151211
def datetime_field(attribute, options = {})
      value = object.send(attribute)
      data = { datepicker: "", timepicker: "" }
      data[:startdate] = I18n.localize(value, format: :decidim_short) if value.present? && value.is_a?(ActiveSupport::TimeWithZone)
      datepicker_format = ruby_format_to_datepicker(I18n.t("time.formats.decidim_short"))
      data[:"date-format"] = datepicker_format

      template = text_field(
        attribute,
        options.merge(data: data)
      )
      help_text = I18n.t("decidim.datepicker.help_text", datepicker_format: datepicker_format)
      template += error_and_help_text(attribute, options.merge(help_text: help_text))
      template.html_safe
    end
813019
def select_simple_date(date_input, value, format = nil)
      value = value.strftime format unless format.nil?

      date_input.set "#{value}\e"
    end
1158636
def _validate_param(param):  # pylint: disable=too-many-branches
    

    detail = None

    if param.oper not in goldman.config.QUERY_FILTERS:
        detail = 'The query filter {} is not a supported ' \
                 'operator. Please change {} & retry your ' \
                 'request'.format(param.oper, param)

    elif param.oper in goldman.config.GEO_FILTERS:
        try:
            if not isinstance(param.val, list) or len(param.val) <= 2:
                raise ValueError
            else:
                param.val = [float(i) for i in param.val]
        except ValueError:
            detail = 'The query filter {} requires a list ' \
                     'of floats for geo evaluation. Please ' \
                     'modify your request & retry'.format(param)

    elif param.oper in goldman.config.ENUM_FILTERS:
        if not isinstance(param.val, list):
            param.val = [param.val]

        param.val = tuple(param.val)

    elif isinstance(param.val, list):
        detail = 'The query filter {} should not be specified more ' \
                 'than once or have multiple values. Please modify ' \
                 'your request & retry'.format(param)

    elif param.oper in goldman.config.BOOL_FILTERS:
        try:
            param.val = str_to_bool(param.val)
        except ValueError:
            detail = 'The query filter {} requires a boolean ' \
                     'for evaluation. Please modify your ' \
                     'request & retry'.format(param)

    elif param.oper in goldman.config.DATE_FILTERS:
        try:
            param.val = str_to_dt(param.val)
        except ValueError:
            detail = 'The query filter {} supports only an ' \
                     'epoch or ISO 8601 timestamp. Please ' \
                     'modify your request & retry'.format(param)

    elif param.oper in goldman.config.NUM_FILTERS:
        try:
            param.val = int(param.val)
        except ValueError:
            detail = 'The query filter {} requires a number ' \
                     'for evaluation. Please modify your ' \
                     'request & retry'.format(param)

    if detail:
        raise InvalidQueryParams(**{
            'detail': detail,
            'links': LINK,
            'parameter': PARAM,
        })
370267
function timestamp (schema, options) {
  options || (options = {})

  // Options
  var fields = {}
    , createdPath = options.createdPath || 'created'
    , modifiedPath = options.modifiedPath || 'modified'
    , useVirtual = (options.useVirtual !== undefined) 
      ? options.useVirtual 
      : true

  // Add paths to schema if not present
  if (!schema.paths[createdPath]) {
    fields[modifiedPath] = { type: Date }
  }
  if (useVirtual) {
    // Use the ObjectID for extracting the created time
    schema.virtual(createdPath).get(function () {
      return new Date(this._id.generationTime * 1000)
    })
  } else {
    if (!schema.paths[createdPath]) {
      fields[createdPath] = { 
        type: Date
      , default: Date.now 
      }
    }
  }
  schema.add(fields)

  // Update the modified timestamp on save
  schema.pre('save', function (next) {
    this[modifiedPath] = new Date
    next()
  })
}
786974
def validate_input parameters
				unless parameters.is_a?(Hash)
					raise StockException, 'Given parameters have to be a hash.'
				end

				# Check if stock symbol is specified.
				unless parameters.has_key?(:symbol)
					raise StockException, 'No stock symbol specified.'
				end
				# Check if stock symbol is a string.
				unless parameters[:symbol].is_a?(String)
					raise StockException, 'Stock symbol must be a string.'
				end

				# Use today date if :end_date is not specified.
				unless parameters.has_key?(:end_date)
					parameters[:end_date] = Date.today.strftime("%Y-%m-%d")
				end

				unless parameters.has_key?(:start_date)
					raise StockException, 'Start date must be specified.'
				end
	 			
				unless DATE_REGEX.match(parameters[:start_date])
					raise StockException, 'Invalid start date specified. Format YYYY-MM-DD.'
				end

				unless DATE_REGEX.match(parameters[:end_date])
					raise StockException, 'Invalid end date specified. Format YYYY-MM-DD.'
				end

				unless parameters[:start_date].to_date < parameters[:end_date].to_date
					raise StockException, 'End date must be greater than the start date.'
				end

				unless parameters[:start_date].to_date < Date.today
					raise StockException, 'Start date must not be in the future.'
				end

				# Set to default :type if key isn't specified.
				parameters[:type] = :daily if !parameters.has_key?(:type)

				unless TYPE_CODES_ARRAY.has_key?(parameters[:type])
					raise StockException, 'Invalid type specified.'
				end
			end
1269961
function parseValueOfType(value, type, options) {
  switch (type) {
    case String:
      return { value }

    case Number:
    case 'Integer':
    case Integer:
      // The global isFinite() function determines
      // whether the passed value is a finite number.
      // If  needed, the parameter is first converted to a number.
      if (!isFinite(value)) {
        return { error: 'invalid' }
      }
      if (type === Integer && !isInteger(value)) {
        return { error: 'invalid' }
      }
      // Convert strings to numbers.
      // Just an additional feature.
      // Won't happen when called from `readXlsx()`.
      if (typeof value === 'string') {
        value = parseFloat(value)
      }
      return { value }

    case 'URL':
    case URL:
      if (!isURL(value)) {
        return { error: 'invalid' }
      }
      return { value }

    case 'Email':
    case Email:
      if (!isEmail(value)) {
        return { error: 'invalid' }
      }
      return { value }

    case Date:
      // XLSX has no specific format for dates.
      // Sometimes a date can be heuristically detected.
      // https://github.com/catamphetamine/read-excel-file/issues/3#issuecomment-395770777
      if (value instanceof Date) {
        return { value }
      }
      if (typeof value === 'number') {
        if (!isFinite(value)) {
          return { error: 'invalid' }
        }
        value = parseInt(value)
        const date = parseDate(value, options.properties)
        if (!date) {
          return { error: 'invalid' }
        }
        return { value: date }
      }
      return { error: 'invalid' }

    case Boolean:
      if (typeof value === 'boolean') {
        return { value }
      }
      return { error: 'invalid' }

    default:
      throw new Error(`Unknown schema type: ${type && type.name || type}`)
  }
}
351540
function parseOptional (params, section, stripped) {
  stripped = stripped.slice(0, -1)
  const key = (params && params[stripped]) || ''

  return {
    dst: key && key.toString() ? section : `/${section}`,
    src: key
  }
}
562044
function(options) {
   	inputEx.DateField.superclass.setOptions.call(this, options);
   	
   	// Overwrite options
   	this.options.className = options.className ? options.className : 'inputEx-Field inputEx-DateField';
   	this.options.messages.invalid = inputEx.messages.invalidDate ? inputEx.messages.invalidDate : "Invalid date, ex: 03/27/2008";
   	
   	// Added options
   	this.options.dateFormat = options.dateFormat || inputEx.messages.defaultDateFormat;
		this.options.valueFormat = options.valueFormat;
   }
1289307
def _process_options(options)
        status, content_type, location = options.values_at(:status, :content_type, :location)

        self.status = status if status
        self.content_type = content_type if content_type
        headers["Location"] = url_for(location) if location

        super
      end