/*
Convert the rule to its equivalent rule using WALL_TIME mode
433916
private static DateTimeRule toWallTimeRule(DateTimeRule rule, int rawOffset, int dstSavings) {
        if (rule.getTimeRuleType() == DateTimeRule.WALL_TIME) {
            return rule;
        }
        int wallt = rule.getRuleMillisInDay();
        if (rule.getTimeRuleType() == DateTimeRule.UTC_TIME) {
            wallt += (rawOffset + dstSavings);
        } else if (rule.getTimeRuleType() == DateTimeRule.STANDARD_TIME) {
            wallt += dstSavings;
        }

        int month = -1, dom = 0, dow = 0, dtype = -1;
        int dshift = 0;
        if (wallt < 0) {
            dshift = -1;
            wallt += Grego.MILLIS_PER_DAY;
        } else if (wallt >= Grego.MILLIS_PER_DAY) {
            dshift = 1;
            wallt -= Grego.MILLIS_PER_DAY;
        }

        month = rule.getRuleMonth();
        dom = rule.getRuleDayOfMonth();
        dow = rule.getRuleDayOfWeek();
        dtype = rule.getDateRuleType();

        if (dshift != 0) {
            if (dtype == DateTimeRule.DOW) {
                // Convert to DOW_GEW_DOM or DOW_LEQ_DOM rule first
                int wim = rule.getRuleWeekInMonth();
                if (wim > 0) {
                    dtype = DateTimeRule.DOW_GEQ_DOM;
                    dom = 7 * (wim - 1) + 1;
                } else {
                    dtype = DateTimeRule.DOW_LEQ_DOM;
                    dom = MONTHLENGTH[month] + 7 * (wim + 1);
                }

            }
            // Shift one day before or after
            dom += dshift;
            if (dom == 0) {
                month--;
                month = month < Calendar.JANUARY ? Calendar.DECEMBER : month;
                dom = MONTHLENGTH[month];
            } else if (dom > MONTHLENGTH[month]) {
                month++;
                month = month > Calendar.DECEMBER ? Calendar.JANUARY : month;
                dom = 1;
            }
            if (dtype != DateTimeRule.DOM) {
                // Adjust day of week
                dow += dshift;
                if (dow < Calendar.SUNDAY) {
                    dow = Calendar.SATURDAY;
                } else if (dow > Calendar.SATURDAY) {
                    dow = Calendar.SUNDAY;
                }
            }
        }
        // Create a new rule
        DateTimeRule modifiedRule;
        if (dtype == DateTimeRule.DOM) {
            modifiedRule = new DateTimeRule(month, dom, wallt, DateTimeRule.WALL_TIME);
        } else {
            modifiedRule = new DateTimeRule(month, dom, dow,
                    (dtype == DateTimeRule.DOW_GEQ_DOM), wallt, DateTimeRule.WALL_TIME);
        }
        return modifiedRule;
    }
24404
private static TimeZoneRule createRuleByRDATE(String tzname,
            int rawOffset, int dstSavings, long start, List<String> dates, int fromOffset) {
        // Create an array of transition times
        long[] times;
        if (dates == null || dates.size() == 0) {
            // When no RDATE line is provided, use start (DTSTART)
            // as the transition time
            times = new long[1];
            times[0] = start;
        } else {
            times = new long[dates.size()];
            int idx = 0;
            try {
                for (String date : dates) {
                    times[idx++] = parseDateTimeString(date, fromOffset);
                }
            } catch (IllegalArgumentException iae) {
                return null;
            }
        }
        return new TimeArrayTimeZoneRule(tzname, rawOffset, dstSavings, times, DateTimeRule.UTC_TIME);
    }
445792
function (inst, timeVal) {
            var retVal = new Object();
            retVal.hours = -1;
            retVal.minutes = -1;

            if(!timeVal)
                return '';

            var timeSeparator = this._get(inst, 'timeSeparator'),
                amPmText = this._get(inst, 'amPmText'),
                showHours = this._get(inst, 'showHours'),
                showMinutes = this._get(inst, 'showMinutes'),
                optionalMinutes = this._get(inst, 'optionalMinutes'),
                showPeriod = (this._get(inst, 'showPeriod') == true),
                p = timeVal.indexOf(timeSeparator);

            // check if time separator found
            if (p != -1) {
                retVal.hours = parseInt(timeVal.substr(0, p), 10);
                retVal.minutes = parseInt(timeVal.substr(p + 1), 10);
            }
            // check for hours only
            else if ( (showHours) && ( !showMinutes || optionalMinutes ) ) {
                retVal.hours = parseInt(timeVal, 10);
            }
            // check for minutes only
            else if ( ( ! showHours) && (showMinutes) ) {
                retVal.minutes = parseInt(timeVal, 10);
            }

            if (showHours) {
                var timeValUpper = timeVal.toUpperCase();
                if ((retVal.hours < 12) && (showPeriod) && (timeValUpper.indexOf(amPmText[1].toUpperCase()) != -1)) {
                    retVal.hours += 12;
                }
                // fix for 12 AM
                if ((retVal.hours == 12) && (showPeriod) && (timeValUpper.indexOf(amPmText[0].toUpperCase()) != -1)) {
                    retVal.hours = 0;
                }
            }

            return retVal;
        }
244780
def cull_to_timestep(self, timestep=1):
        """"""
        valid_s = self.header.analysis_period.VALIDTIMESTEPS.keys()
        assert timestep in valid_s, \
            'timestep {} is not valid. Choose from: {}'.format(timestep, valid_s)

        new_ap, new_values, new_datetimes = self._timestep_cull(timestep)
        new_header = self.header.duplicate()
        new_header._analysis_period = new_ap
        new_coll = HourlyDiscontinuousCollection(
            new_header, new_values, new_datetimes)
        new_coll._validated_a_period = True
        return new_coll
427657
function convertRawTimestampHelper(
    epochFracSecsBig,
    scale,
    timezone,
    format)
{
  // compute the scale factor
  var scaleFactor = Math.pow(10, scale);

  // split the value into epoch seconds + nanoseconds; for example,
  // 1365148923.123456789 will be split into 1365148923 (epoch seconds)
  // and 123456789 (nano seconds)
  var valSecBig = epochFracSecsBig.dividedBy(scaleFactor).floor();
  var fractionsBig = epochFracSecsBig.minus(valSecBig.times(scaleFactor));
  var valSecNanoBig = fractionsBig.times(Math.pow(10, 9 - scale));

  // create a new snowflake date from the information
  return new SfTimestamp(
      valSecBig.toNumber(),
      valSecNanoBig.toNumber(),
      scale,
      timezone,
      format);
}
54171
function actualize (entry, rule, year) {
    var actualized, date = rule.day[1];

    do {
      actualized = new Date(Date.UTC(year, rule.month, Math.abs(date++)));
    } while (rule.day[0] < 7 && actualized.getUTCDay() != rule.day[0])

    actualized = {
      clock: rule.clock,
      sort: actualized.getTime(),
      rule: rule,
      save: rule.save * 6e4,
      offset: entry.offset
    };

    actualized[actualized.clock] = actualized.sort + rule.time * 6e4;

    if (actualized.posix) {
      actualized.wallclock = actualized[actualized.clock] + (entry.offset + rule.saved);
    } else {
      actualized.posix = actualized[actualized.clock] - (entry.offset + rule.saved);
    }

    return actualized;
  }
354727
function getFuzzyTimezoneFromTile(tile) {
  if (tile[2] === z) {
    var key = tile.join('/');
    if (key in tiles) return tiles[key];
    else throw new Error('tile not found');

  } else if (tile[2] > z) {
    // higher zoom level (9, 10, 11, ...)
    key = _getParent(tile).join('/');
    if (key in tiles) return tiles[key];
    else throw new Error('tile not found');

  } else {
    // lower zoom level (..., 5, 6, 7)
    var children = _getChildren(tile);
    var votes = [];  // list of timezone abbrevations
    var abbrs = {};  // abbrevation to full name lookup table
    children.forEach(function(child) {
      key = child.join('/');
      if (key in tiles) {
        var tz = tiles[key];   // timezone name

        // Need to use timezone abbreviation becuase e.g. America/Los_Angeles
        // and America/Vancouver are the same. Use a time to determine the
        // abbreviation, in case two similar tz have slightly different
        // daylight savings schedule.
        var abbr = moment.tz(Date.now(), tz)._z.abbrs[0];
        votes.push(abbr);
        abbrs[abbr] = tz;
      }
    });

    if (votes.length > 1) return abbrs[ss.mode(votes)];
    else throw new Error('tile not found');
  }
}
129516
def set_timelimit(self, timelimit):
        """"""
        super().set_timelimit(timelimit)
        self.qparams["wall_clock_limit"] = qu.time2loadlever(timelimit)
1024740
function (timeFormat) {
		var tf = timeFormat.replace(/'.*?'/g, '').toLowerCase(), // removes literals
			isIn = function (f, t) { // does the format contain the token?
					return f.indexOf(t) !== -1 ? true : false;
				};
		return {
				hour: isIn(tf, 'h'),
				minute: isIn(tf, 'm'),
				second: isIn(tf, 's'),
				millisec: isIn(tf, 'l'),
				microsec: isIn(tf, 'c'),
				timezone: isIn(tf, 'z'),
				ampm: isIn(tf, 't') && isIn(timeFormat, 'h'),
				iso8601: isIn(timeFormat, 'Z')
			};
	}
583818
function convert(dateTime, pattern, options) {
	// If no pattern provided setting default one
	var defaultPattern = pattern || '%hh%:%mm% %DD%/%MM%/%YYYY%';
	
	const filters = [
		{
			pattern: /%hh%/g,
			replacement: (function() {
				if(options && options.shortTime && dateTime.getHours() > 12) {
					return dateTime.getHours() - 12;
				} else {
					return validateForOneDigit(dateTime.getHours());
				}
			})()
		},
		{
			pattern: /%mm%/g,
			replacement: validateForOneDigit(dateTime.getMinutes())
		},
		{
			pattern: /%ss%/g,
			replacement: validateForOneDigit(dateTime.getSeconds())
		},
		{
			pattern: /%DD%/g,
			replacement: validateForOneDigit(dateTime.getDate())
		},
		{
			pattern: /%MM%/g,
			replacement: validateForOneDigit(dateTime.getMonth() + 1)
		},
		{
			pattern: /%YYYY%/g,
			replacement: validateForOneDigit(dateTime.getFullYear())
		},
		{
			pattern: /%YY%/g,	//TODO
			replacement: validateForOneDigit(dateTime.getFullYear().toString().slice(2))
		},
		{
			pattern: /%h%/g,
			replacement: (function() {
				if(options && options.shortTime && dateTime.getHours() > 12) {
					return dateTime.getHours() - 12;
				} else {
					return dateTime.getHours();
				}
			})()
		},
		{
			pattern: /%m%/g,
			replacement: dateTime.getMinutes()
		},
		{
			pattern: /%s%/g,
			replacement: dateTime.getSeconds()
		},
		{
			pattern: /%D%/g,
			replacement: dateTime.getDate()
		},
		{
			pattern: /%M%/g,
			replacement: dateTime.getMonth() + 1
		},
		{
			pattern: /%day%/g,
			replacement: days[dateTime.getDay()]
		},
		{
			pattern: /%month%/g,
			replacement: months[dateTime.getMonth()]
		},
		{
			pattern: /%relative%/g,
			replacement: relative(dateTime)
		},
		{
			pattern: /%12h%/g,
			replacement: (function() {
				if(options && options.shortTime) {
					if(dateTime.getHours() > 11) {
						return 'PM';
					} else {
						return 'AM';
					}
				}
			})()
		}
	];
	
	filters.forEach(function(f) {
		defaultPattern = defaultPattern.replace(f.pattern, f.replacement);
	});
	
	if(options && options.shortTime &&
	  pattern.indexOf('%12h%') === -1) {
		if(dateTime.getHours() > 11) {
			defaultPattern += ' PM';
		} else {
			defaultPattern += ' AM';
		}
	}

	return defaultPattern;
}
961600
def FromTimedelta(self, td):
    """"""
    self._NormalizeDuration(td.seconds + td.days * _SECONDS_PER_DAY,
                            td.microseconds * _NANOS_PER_MICROSECOND)
357914
def compile_datetime(rule):
    
    if isinstance(rule.value, datetime.datetime):
        return rule
    try:
        # Try numeric type
        return DatetimeRule(datetime.datetime.fromtimestamp(float(rule.value)))
    except (TypeError, ValueError):
        pass
    # Try RFC3339 timestamp string
    res = TIMESTAMP_RE.match(str(rule.value))
    if res is not None:
        year, month, day, hour, minute, second = (int(n or 0) for n in res.group(*range(1, 7)))
        us_str = (res.group(7) or "0")[:6].ljust(6, "0")
        us_int = int(us_str)
        zonestr = res.group(8)
        zonespl = (0, 0) if zonestr in ['z', 'Z'] else [int(i) for i in zonestr.split(":")]
        zonediff = datetime.timedelta(minutes = zonespl[0]*60+zonespl[1])
        return DatetimeRule(datetime.datetime(year, month, day, hour, minute, second, us_int) - zonediff)
    raise ValueError("Wrong datetime format '{}'".format(rule.value))
1132447
def to_native(self):
        
        h, m, s = self.hour_minute_second
        s, ns = nano_divmod(s, 1)
        ms = int(nano_mul(ns, 1000000))
        return time(h, m, s, ms)
999986
function(rule){
    rule = basis.getter(rule || UNION);

    if (this.rule !== rule)
    {
      var oldRule = this.rule;

      this.rule = rule;
      this.emit_ruleChanged(oldRule);

      return this.applyRule();
    }
  }
581794
function convertRules (config) {
  const result = {}

  const eslintRules = new CLIEngine({
    useEslintrc: false,
    baseConfig: {
      extends: [require.resolve(`@vue/eslint-config-${config}`)]
    }
  }).getConfigForFile().rules

  const getRuleOptions = (ruleName, defaultOptions = []) => {
    const ruleConfig = eslintRules[ruleName]

    if (!ruleConfig || ruleConfig === 0 || ruleConfig === 'off') {
      return
    }

    if (Array.isArray(ruleConfig) && (ruleConfig[0] === 0 || ruleConfig[0] === 'off')) {
      return
    }

    if (Array.isArray(ruleConfig) && ruleConfig.length > 1) {
      return ruleConfig.slice(1)
    }

    return defaultOptions
  }

  // https://eslint.org/docs/rules/indent
  const indent = getRuleOptions('indent', [4])
  if (indent) {
    result.indent_style = indent[0] === 'tab' ? 'tab' : 'space'

    if (typeof indent[0] === 'number') {
      result.indent_size = indent[0]
    }
  }

  // https://eslint.org/docs/rules/linebreak-style
  const linebreakStyle = getRuleOptions('linebreak-style', ['unix'])
  if (linebreakStyle) {
    result.end_of_line = linebreakStyle[0] === 'unix' ? 'lf' : 'crlf'
  }

  // https://eslint.org/docs/rules/no-trailing-spaces
  const noTrailingSpaces = getRuleOptions('no-trailing-spaces', [{ skipBlankLines: false, ignoreComments: false }])
  if (noTrailingSpaces) {
    if (!noTrailingSpaces[0].skipBlankLines && !noTrailingSpaces[0].ignoreComments) {
      result.trim_trailing_whitespace = true
    }
  }

  // https://eslint.org/docs/rules/eol-last
  const eolLast = getRuleOptions('eol-last', ['always'])
  if (eolLast) {
    result.insert_final_newline = eolLast[0] !== 'never'
  }

  // https://eslint.org/docs/rules/max-len
  const maxLen = getRuleOptions('max-len', [{ code: 80 }])
  if (maxLen) {
    // To simplify the implementation logic, we only read from the `code` option.

    // `max-len` has an undocumented array-style configuration,
    // where max code length specified directly as integers
    // (used by `eslint-config-airbnb`).

    if (typeof maxLen[0] === 'number') {
      result.max_line_length = maxLen[0]
    } else {
      result.max_line_length = maxLen[0].code
    }
  }

  return result
}
1311575
function isTimeSmallerOrEquals(time1, time2, doNotInvolveMinutePart) {
			var regex = '^(-|\\+)?([0-9]+)(.([0-9]{1,2}))?$';
			(new RegExp(regex, 'i')).test(time1);
			var t1 = parseInt(RegExp.$2) * 60;
			if (RegExp.$4 && !doNotInvolveMinutePart) t1 += parseInt(RegExp.$4);
			if (RegExp.$1 == '-') t1 *= -1;
			(new RegExp(regex, 'i')).test(time2);
			var t2 = parseInt(RegExp.$2) * 60;
			if (RegExp.$4 && !doNotInvolveMinutePart) t2 += parseInt(RegExp.$4);
			if (RegExp.$1 == '-') t2 *= -1;
			if (t1 <= t2) return true;
			else return false;
		}
811090
function asUtcTime(time) {
      var date = dateBase(time);
      if (!date.getTime()) return NaN;
      return Date.UTC(
        date.getFullYear(), date.getMonth(), date.getDate(),
        date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()
      );
    }