Helper function for the convertRawTimestamp*() functions.
Returns an instance of SfTimestamp.

@param {Object} epochFracSecsBig
@param {Number} scale
@param {String | Number} timezone
@param {String} format

@returns {Object}
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);
}
1033423
public static function getTimezoneLabel($tz_id, $format = false, $ts = 'now') {
		if (self::isValidTimezone($tz_id) && $format) {
			$dt = new DateTime(null, new DateTimeZone($tz_id));
			(is_int($ts)) ? $dt->setTimestamp($ts) : $dt->modify($ts);
			return $dt->format($format);
		}

		return elgg_echo($tz_id);
	}
1282465
function (durationInNanoSeconds) {
        // convert it to MILLI_SECONDS
        var durationInMillis = _.floor(durationInNanoSeconds / 1000000);

        var oneMilliSecond = 1000;
        var oneMinute = 60 * oneMilliSecond;
        var formattedDuration = '0s';

        function format(min, sec, ms) {
            var MINUTES = 'm ';
            var SECONDS = 's ';
            var MILLI_SECONDS = 'ms';
            var formattedTimeStamp = '';

            min > 0 ? formattedTimeStamp += min + MINUTES : '';
            sec > 0 ? formattedTimeStamp += sec + SECONDS : '';
            ms > 0 ? formattedTimeStamp += ms + MILLI_SECONDS : '';

            return formattedTimeStamp.trim().length === 0 ? '< 1ms' : formattedTimeStamp;
        }

        if (!isNaN(durationInMillis)) {

            var min = _.floor(durationInMillis / oneMinute);
            var sec = _.floor((durationInMillis % oneMinute) / oneMilliSecond);
            var ms = durationInMillis % oneMilliSecond;

            formattedDuration = format(min, sec, ms);
        }

        return formattedDuration;
    }
1114662
function translateDateTimestamp(timestamp) {
    if (!timestamp) {
        LOG.warn("Received an invalid timestamp: {}", timestamp);
        return Date.now();
    }

    return new Date(timestamp);
}
613122
static String getFormattedTimestamp() {
        DateFormat df = dateFormatPool.getAndSet(null);
        if (df == null) {
            df = createISODateFormat();
        }
        String timestamp = df.format(new Date());
        dateFormatPool.set(df);
        return timestamp;
    }
156032
static public String getFormattedDateTime(long dt, TimeZone tz, String format)
    {
        SimpleDateFormat df = new SimpleDateFormat(format);
        if(tz != null)
            df.setTimeZone(tz);
        return df.format(new Date(dt));
    }
684746
public static String getTime(long epochTimestamp, String timeFormat,
            ZoneId zoneId) {
        return getTime(epochTimestamp, getDateTimeFormatter(timeFormat),
                zoneId);
    }
350697
public static String changeTimestampToNewFormat(String originDateFormat,
            String originTimestamp, String newDateFormat) {
        return getTime(
                changeTimestampToLong(getSimpleDateFormat(originDateFormat),
                        originTimestamp), newDateFormat);
    }
17298
function toTimestamp(date) {
    var value =
        (typeof date === 'number') ? date :           // number
        (date instanceof Date)     ? date.valueOf() : // Date
        new Date(date).valueOf();                     // ISOString, momentjs, ...

    if (isNaN(value)) {
      throw new TypeError('Invalid date ' + JSON.stringify(date) + '. ' +
          'Date, number, or ISOString expected');
    }

    return value;
  }
209430
public static String getCurrentTimestamp(String timeFormat, String zoneId) {
        return getTime(System.currentTimeMillis(), timeFormat, zoneId);
    }
1225262
static public long getDateTime(String s, String format, TimeZone tz)
    {
        long ret = 0L;
        SimpleDateFormat df = null;

        try
        {
            if(s != null && s.length() > 0)
            {
                df = formatPool.getFormat(format);
                df.setTimeZone(tz);
                Date dt = df.parse(s);
                ret = dt.getTime();
            }
        }
        catch(Exception e)
        {
        }

        if(df != null)
            formatPool.release(df);

        return ret;
    }
523699
public static function formatTimestamp($firstTimestamp, $secondTimestamp = null, $returnAsArray = false)
    {
        if ($secondTimestamp === null) {
            $secondTimestamp = time();
        }

        $startDiff = $diff = abs($firstTimestamp - $secondTimestamp);

        $suffixes = array(
            array('single' => 'second', 'multi' => 'seconds', 'div' => 60, 'cap' => 60),
            array('single' => 'minute', 'multi' => 'minutes', 'div' => 3600, 'cap' => 60),
            array('single' => 'hour', 'multi' => 'hours', 'div' => 86400, 'cap' => 24),
            array('single' => 'day', 'multi' => 'days', 'div' => 604800, 'cap' => 7),
            array('single' => 'week', 'multi' => 'weeks', 'div' => 2629743.83, 'cap' => 4),
            array('single' => 'month', 'multi' => 'months', 'div' => 31556925, 'cap' => 12),
            array('single' => 'year', 'multi' => 'years', 'div' => 0, 'cap' => 0),
        );

        foreach ($suffixes as $suffixRow) {
            $single = $suffixRow['single'];
            $multi = $suffixRow['multi'];
            $div = $suffixRow['div'];
            $cap = $suffixRow['cap'];

            if (!$cap) {
                break;
            }

            if ($diff < $cap) {
                if ($returnAsArray) {
                    return array($diff, ($diff === 1 ? $single : $multi));
                }

                return $diff.' '.($diff === 1 ? $single : $multi);
            }

            $diff = (int) round($startDiff / $div);
        }

        if ($returnAsArray) {
            return array($diff, ($diff === 1 ? $single : $multi));
        }

        return $diff.' '.($diff === 1 ? $single : $multi);
    }
844794
static public void encodeTimestamp(final FastSerializer fs, TimestampType value)
    throws IOException {
        final long lvalue = value.getTime();
        fs.writeLong(lvalue);
    }
1101706
private static TimeScaleData getTimeScaleData(int scale)
    {
        if (scale < 0 || scale >= MAX_SCALE) {
            throw new IllegalArgumentException("scale out of range: " + scale);
        }
        
        return timeScaleTable[scale];
    }
1191665
def _format_return_timestamps(self, return_timestamps=None):
        
        if return_timestamps is None:
            # Build based upon model file Start, Stop times and Saveper
            # Vensim's standard is to expect that the data set includes the `final time`,
            # so we have to add an extra period to make sure we get that value in what
            # numpy's `arange` gives us.
            return_timestamps_array = np.arange(
                self.components.initial_time(),
                self.components.final_time() + self.components.saveper(),
                self.components.saveper(), dtype=np.float64
            )
        elif inspect.isclass(range) and isinstance(return_timestamps, range):
            return_timestamps_array = np.array(return_timestamps, ndmin=1)
        elif isinstance(return_timestamps, (list, int, float, np.ndarray)):
            return_timestamps_array = np.array(return_timestamps, ndmin=1)
        elif isinstance(return_timestamps, _pd.Series):
            return_timestamps_array = return_timestamps.as_matrix()
        else:
            raise TypeError('`return_timestamps` expects a list, array, pandas Series, '
                            'or numeric value')
        return return_timestamps_array
354923
function parseTimeStamp(input) {

    function computeSeconds(h, m, s, f) {
      return (h | 0) * 3600 + (m | 0) * 60 + (s | 0) + (f | 0) / 1000;
    }

    var m = input.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);
    if (!m) {
      return null;
    }

    if (m[3]) {
      // Timestamp takes the form of [hours]:[minutes]:[seconds].[milliseconds]
      return computeSeconds(m[1], m[2], m[3].replace(":", ""), m[4]);
    } else if (m[1] > 59) {
      // Timestamp takes the form of [hours]:[minutes].[milliseconds]
      // First position is hours as it's over 59.
      return computeSeconds(m[1], m[2], 0,  m[4]);
    } else {
      // Timestamp takes the form of [minutes]:[seconds].[milliseconds]
      return computeSeconds(0, m[1], m[2], m[4]);
    }
  }
278118
public static String dateFormat(long ts, String format, TimeZone tz) {
		SimpleDateFormat formatter = FORMATTER_CACHE.get(format);
		formatter.setTimeZone(tz);
		Date dateTime = new Date(ts);
		return formatter.format(dateTime);
	}