is text a time or timezone
i.e. HH-MM-SS or z+-HH-MM-SS 08:43 | 15:23:00:0567 | 10:34pm | 10:34 p.m. | +01:00:00 | -02:00 | z15:00 | 0843

@param  {String} text
@return {Boolean}
491273
function( text ) {
			if(modules.utils.isString(text)){
				text = text.toLowerCase();
				text = modules.utils.trim( text );
				// start with timezone char
				if( text.match(':') && ( modules.utils.startWith(text, 'z') || modules.utils.startWith(text, '-')  || modules.utils.startWith(text, '+') )) {
					return true;
				}
				// has ante meridiem or post meridiem
				if( text.match(/^[0-9]/) &&
					( this.hasAM(text) || this.hasPM(text) )) {
					return true;
				}
				// contains time delimiter but not datetime delimiter
				if( text.match(':') && !text.match(/t|\s/) ) {
					return true;
				}

				// if it's a number of 2, 4 or 6 chars
				if(modules.utils.isNumber(text)){
					if(text.length === 2 || text.length === 4 || text.length === 6){
						return true;
					}
				}
			}
			return false;
		}
582818
function( time ) {
		var h, m, s;

		if ( time > TIME_MINUTE ) {
			m = parseInt( time / TIME_MINUTE, 10 );
			s = ( time % TIME_MINUTE ) / TIME_SECOND;
			return m + 'mins, ' + s + 's';
		}
		else if ( time > TIME_SECOND ) {
			return ( time / TIME_SECOND ) + 's';
		}
		else {
			return time + 'ms';
		}
	}
901410
function (timestamp) {
        var time = (new Date(timestamp)).toISOString();
        return {
            msg       : time,
            msgLength : time.length
        };
    }
789108
function(date) {
		var minutes = date.getMinutes().toString();
		var hours = date.getHours().toString();
		return this.zeroPad(2, hours) + ":" + this.zeroPad(2, minutes);
	}
584447
def what_time_is_it(self, message):
        """"""
        now = datetime.datetime.now()
        self.say("It's %s." % self.to_natural_day_and_time(now, with_timezone=True), message=message)
689401
def parse(text, base=None, chop=False):
    '''
    
    '''
    #TODO: use base to facilitate relative time offsets
    text = text.strip().lower()
    text = (''.join([c for c in text if c.isdigit()]))

    if chop:
        text = text[:17]

    # TODO: support relative time offsets here...

    tlen = len(text)
    if tlen == 4:
        dt = datetime.datetime.strptime(text, '%Y')

    elif tlen == 6:
        dt = datetime.datetime.strptime(text, '%Y%m')

    elif tlen == 8:
        dt = datetime.datetime.strptime(text, '%Y%m%d')

    elif tlen == 10:
        dt = datetime.datetime.strptime(text, '%Y%m%d%H')

    elif tlen == 12:
        dt = datetime.datetime.strptime(text, '%Y%m%d%H%M')

    elif tlen == 14:
        dt = datetime.datetime.strptime(text, '%Y%m%d%H%M%S')

    elif tlen in (15, 16, 17):
        dt = datetime.datetime.strptime(text, '%Y%m%d%H%M%S%f')

    else:
        raise s_exc.BadTypeValu(valu=text, name='time',
                                mesg='Unknown time format')

    epoch = datetime.datetime(1970, 1, 1)
    return int((dt - epoch).total_seconds() * 1000)
408249
private static Date extractDate(String text, Locale locale) {
		DateFormat fmt;
		for (int style = 0; style <= 3; ++style) {
			// Date and time parsing
			for (int style2 = 0; style2 <= 3; ++style2) {
				fmt = DateFormat.getDateTimeInstance(style, style2, locale);
				try {
					return fmt.parse(text);
				} catch (ParseException exception) {
					//
				}
			}
			// Date only parsing
			fmt = DateFormat.getDateInstance(style, locale);
			try {
				return fmt.parse(text);
			} catch (ParseException exception) {
				//
			}
			// Time only parsing
			fmt = DateFormat.getTimeInstance(style, locale);
			try {
				return fmt.parse(text);
			} catch (ParseException exception) {
				//
			}
		}
		return null;
	}
320024
function timestamp() {
  var d = new Date();
  return d.getHours() + ':' + pad2(d.getMinutes()) + ':' + pad2(d.getSeconds());
}
1329748
public static final boolean isTime(String str)
    {
        int length = str.length();
        if ( length > 8 ) {
            return false;
        }
        
        int sIdx = 0, eIdx = 0, idx = 0;
        String[] parts = new String[]{null,null,null};
        while ( (eIdx = str.indexOf(':', sIdx)) > -1 ) {
            parts[idx++] = str.substring(sIdx, eIdx);
            sIdx = eIdx + 1;
            if ( idx > 2 ) {
                return false;
            }
        }
        
        if ( sIdx < length ) {
            parts[idx++] = str.substring(sIdx);
        }
        
        if ( idx < 2 || idx > 3 ) {
            return false;
        }
        
        String h,i,s = null;
        if ( idx == 2 ) {
            h = parts[0];
            i = parts[1];
        } else {
            h = parts[0];
            i = parts[1];
            s = parts[2];
        }
        
        //hour format check
        int len = h.length();
        if ( len < 1 || len > 2 ) {
            return false;
        }
        
        if ( len == 1 ) {
            char chr = h.charAt(0);
            if ( chr < '0' || chr > '9' ) {
                return false;
            }
        } else if ( len == 2 ) {
            char chr1 = h.charAt(0);
            char chr2 = h.charAt(1);
            if ( chr1 == '0' || chr1 == '1' ) {
                if ( chr2 < '0' || chr2 > '9' ) {
                    return false;
                }
            } else if ( chr1 == '2' ) {
                if ( chr2 < '0' || chr2 > '4' ) {
                    return false;
                }
            } else {
                return false;
            }
        }
        
        //minute format check
        len = i.length();
        if ( len < 1 || len > 2 ) {
            return false;
        }
        
        if ( len == 1 ) {
            char chr = i.charAt(0);
            if ( chr < '0' || chr > '9' ) {
                return false;
            }
        } else if ( len == 2 ) {
            char chr1 = i.charAt(0);
            char chr2 = i.charAt(1);
            if ( chr1 >= '0' && chr1 <= '5' ) {
                if ( chr2 < '0' || chr2 > '9' ) {
                    return false;
                }
            } else {
                return false;
            }
        }
        
        //second format check
        if ( idx == 3 ) {
            len = s.length();
            if ( len < 1 || len > 2 ) {
                return false;
            }
            
            if ( len == 1 ) {
                char chr = s.charAt(0);
                if ( chr < '0' || chr > '9' ) {
                    return false;
                }
            } else if ( len == 2 ) {
                char chr1 = s.charAt(0);
                char chr2 = s.charAt(1);
                if ( chr1 >= '0' && chr1 <= '5' ) {
                    if ( chr2 < '0' || chr2 > '9' ) {
                        return false;
                    }
                } else {
                    return false;
                }
            }
        }
        
        return true;
    }
1311275
def parse_timezone(matches, default_timezone=UTC):
    

    if matches["timezone"] == "Z":
        return UTC
    # This isn't strictly correct, but it's common to encounter dates without
    # timezones so I'll assume the default (which defaults to UTC).
    # Addresses issue 4.
    if matches["timezone"] is None:
        return default_timezone
    sign = matches["tz_sign"]
    hours = to_int(matches, "tz_hour")
    minutes = to_int(matches, "tz_minute", default_to_zero=True)
    description = "%s%02d:%02d" % (sign, hours, minutes)
    if sign == "-":
        hours = -hours
        minutes = -minutes
    return FixedOffset(hours, minutes, description)
178986
function compareTimeZones(a, b) {
    if (typeof a !== 'string' || typeof b !== 'string') {
      return NaN;
    }

    return normalizeIso8601TimeZone(a) - normalizeIso8601TimeZone(b);
  }
1165292
public static Duration decode(String text, int hoursInDay) {
    int days = 0;
    int hours = 0;
    int minutes = 0;
    String sanitizedText = StringUtils.deleteWhitespace(text);
    Pattern pattern = Pattern.compile("\\s*+(?:(\\d++)\\s*+" + DAY + ")?+\\s*+(?:(\\d++)\\s*+" + HOUR + ")?+\\s*+(?:(\\d++)\\s*+" + MINUTE + ")?+\\s*+");
    Matcher matcher = pattern.matcher(text);

    try {
      if (matcher.find()) {
        String daysDuration = matcher.group(1);
        if (daysDuration != null) {
          days = Integer.parseInt(daysDuration);
          sanitizedText = sanitizedText.replace(daysDuration + DAY, "");
        }
        String hoursText = matcher.group(2);
        if (hoursText != null) {
          hours = Integer.parseInt(hoursText);
          sanitizedText = sanitizedText.replace(hoursText + HOUR, "");
        }
        String minutesText = matcher.group(3);
        if (minutesText != null) {
          minutes = Integer.parseInt(minutesText);
          sanitizedText = sanitizedText.replace(minutesText + MINUTE, "");
        }
        if (sanitizedText.isEmpty()) {
          return new Duration(days, hours, minutes, hoursInDay);
        }
      }
      throw invalid(text, null);
    } catch (NumberFormatException e) {
      throw invalid(text, e);
    }
  }
424510
def parse_iso8601(text):
    
    parsed = _parse_iso8601_duration(text)
    if parsed is not None:
        return parsed

    m = ISO8601_DT.match(text)
    if not m:
        raise ParserError("Invalid ISO 8601 string")

    ambiguous_date = False
    is_date = False
    is_time = False
    year = 0
    month = 1
    day = 1
    minute = 0
    second = 0
    microsecond = 0
    tzinfo = None

    if m:
        if m.group("date"):
            # A date has been specified
            is_date = True

            if m.group("isocalendar"):
                # We have a ISO 8601 string defined
                # by week number
                if (
                    m.group("weeksep")
                    and not m.group("weekdaysep")
                    and m.group("isoweekday")
                ):
                    raise ParserError("Invalid date string: {}".format(text))

                if not m.group("weeksep") and m.group("weekdaysep"):
                    raise ParserError("Invalid date string: {}".format(text))

                try:
                    date = _get_iso_8601_week(
                        m.group("isoyear"), m.group("isoweek"), m.group("isoweekday")
                    )
                except ParserError:
                    raise
                except ValueError:
                    raise ParserError("Invalid date string: {}".format(text))

                year = date["year"]
                month = date["month"]
                day = date["day"]
            else:
                # We have a classic date representation
                year = int(m.group("year"))

                if not m.group("monthday"):
                    # No month and day
                    month = 1
                    day = 1
                else:
                    if m.group("month") and m.group("day"):
                        # Month and day
                        if not m.group("daysep") and len(m.group("day")) == 1:
                            # Ordinal day
                            ordinal = int(m.group("month") + m.group("day"))
                            leap = is_leap(year)
                            months_offsets = MONTHS_OFFSETS[leap]

                            if ordinal > months_offsets[13]:
                                raise ParserError("Ordinal day is out of range")

                            for i in range(1, 14):
                                if ordinal <= months_offsets[i]:
                                    day = ordinal - months_offsets[i - 1]
                                    month = i - 1

                                    break
                        else:
                            month = int(m.group("month"))
                            day = int(m.group("day"))
                    else:
                        # Only month
                        if not m.group("monthsep"):
                            # The date looks like 201207
                            # which is invalid for a date
                            # But it might be a time in the form hhmmss
                            ambiguous_date = True

                        month = int(m.group("month"))
                        day = 1

        if not m.group("time"):
            # No time has been specified
            if ambiguous_date:
                # We can "safely" assume that the ambiguous date
                # was actually a time in the form hhmmss
                hhmmss = "{}{:0>2}".format(str(year), str(month))

                return datetime.time(int(hhmmss[:2]), int(hhmmss[2:4]), int(hhmmss[4:]))

            return datetime.date(year, month, day)

        if ambiguous_date:
            raise ParserError("Invalid date string: {}".format(text))

        if is_date and not m.group("timesep"):
            raise ParserError("Invalid date string: {}".format(text))

        if not is_date:
            is_time = True

        # Grabbing hh:mm:ss
        hour = int(m.group("hour"))
        minsep = m.group("minsep")

        if m.group("minute"):
            minute = int(m.group("minute"))
        elif minsep:
            raise ParserError("Invalid ISO 8601 time part")

        secsep = m.group("secsep")
        if secsep and not minsep and m.group("minute"):
            # minute/second separator but no hour/minute separator
            raise ParserError("Invalid ISO 8601 time part")

        if m.group("second"):
            if not secsep and minsep:
                # No minute/second separator but hour/minute separator
                raise ParserError("Invalid ISO 8601 time part")

            second = int(m.group("second"))
        elif secsep:
            raise ParserError("Invalid ISO 8601 time part")

        # Grabbing subseconds, if any
        if m.group("subsecondsection"):
            # Limiting to 6 chars
            subsecond = m.group("subsecond")[:6]

            microsecond = int("{:0<6}".format(subsecond))

        # Grabbing timezone, if any
        tz = m.group("tz")
        if tz:
            if tz == "Z":
                offset = 0
            else:
                negative = True if tz.startswith("-") else False
                tz = tz[1:]
                if ":" not in tz:
                    if len(tz) == 2:
                        tz = "{}00".format(tz)

                    off_hour = tz[0:2]
                    off_minute = tz[2:4]
                else:
                    off_hour, off_minute = tz.split(":")

                offset = ((int(off_hour) * 60) + int(off_minute)) * 60

                if negative:
                    offset = -1 * offset

            tzinfo = FixedTimezone(offset)

        if is_time:
            return datetime.time(hour, minute, second, microsecond)

        return datetime.datetime(
            year, month, day, hour, minute, second, microsecond, tzinfo=tzinfo
        )
1211395
public static function check($text = "") {
		
		// make sure start time is set
		if (empty(self::$startTime)) {
			Console::writeError("the timer wasn't started...");
		}
		
		// make sure check time is set
		if (empty(self::$checkTime)) {
			self::$checkTime = self::$startTime;
		}
		
		// format any extra text
		$insert = "";
		if (!empty($text)) {
			$insert = "<info>".$text." >> </info>";
		}
		
		// get the current time
		$checkTime = self::getTime();
		
		// get the data for the output
		$totalTime = ($checkTime - self::$startTime);
		$mem       = round((memory_get_peak_usage(true)/1024)/1024,2);
		
		// figure out what tag to show
		$timeTag = "info";
		if (($checkTime - self::$checkTime) > 0.2) {
			$timeTag = "error";
		} else if (($checkTime - self::$checkTime) > 0.1) {
			$timeTag = "warning";
		}
		
		// set the checkTime for the next check comparison
		self::$checkTime = $checkTime;
		
		// write out time/mem stats
		Console::writeLine($insert."currently taken <".$timeTag.">".$totalTime."</".$timeTag."> seconds and used <info>".$mem."MB</info> of memory...");
		
	}
1307498
function (time) {
      var split = time.split(':');
      var hour = parseInt(split[0]);
      var mn = parseInt(split[1]);

      if (this.settings.hour === 12) {
        var matches = time.match(/([0-1]?[0-9]):?([0-5][0-9])?\s?(am|pm|p)?/);
        var ind = matches[3];
        if (!ind) {
          ind = 'am';
        }

        hour = parseInt(matches[1]);
        mn = parseInt(matches[2]);

        if (!mn) {
          mn = 0;
        }

        if (hour === 12 && ind === 'am') {
          hour = 0;
        }
        if (hour === 12 && (ind === 'pm' || ind === 'p')) {
          ind = 'am';
        }
        if (ind === 'pm' || ind === 'p') {
          hour += 12;
        }
      }

      var position = 0;
      position += hour * this.periodInterval;
      position += mn / 60 * this.periodInterval;

      if (Math.floor(position) !== position) {
        return -1;
      }

      return position;
    }
714097
def text(self, value):
        
        self._text = value
        self.timestamps.edited = datetime.datetime.utcnow()
        self.touch(True)
1296863
function getLetterTime(timeString) {
  var totalSeconds = 0;
  var timeValues = {
    's': 1,
    'm': 1 * 60,
    'h': 1 * 60 * 60,
    'd': 1 * 60 * 60 * 24,
    'w': 1 * 60 * 60 * 24 * 7,
  };
  var timePairs;

  //expand to "1 h 30 m 20 s" and split
  timeString = timeString.replace(/([smhdw])/g, ' $1 ').trim();
  timePairs = timeString.split(' ');

  for (var i = 0; i < timePairs.length; i += 2) {
    totalSeconds += parseInt(timePairs[i], 10) *
      timeValues[timePairs[i + 1] || 's'];
  }
  return totalSeconds;
}