Pretty print travel times.
548359
def output(self) -> None:
        """"""
        print("%s - %s" % (self.station, self.now))
        print(self.products_filter)

        for j in sorted(self.journeys, key=lambda k: k.real_departure)[
            : self.max_journeys
        ]:
            print("-------------")
            print(f"{j.product}: {j.number} ({j.train_id})")
            print(f"Richtung: {j.direction}")
            print(f"Abfahrt in {j.real_departure} min.")
            print(f"Abfahrt {j.departure.time()} (+{j.delay})")
            print(f"Nächste Haltestellen: {([s['station'] for s in j.stops])}")
            if j.info:
                print(f"Hinweis: {j.info}")
                print(f"Hinweis (lang): {j.info_long}")
            print(f"Icon: {j.icon}")
724261
void formatMinutes(StringBuilder b, ZonedDateTime d, int width) {
    zeroPad2(b, d.getMinute(), width);
  }
973255
public static String prettyDateTime(String time) {
        if (time.length() < 12) return time;
        StringBuilder sb = new StringBuilder();
        sb.append(time.substring(0, 4)).append("-").append(time.substring(4, 6)).append("-").append(time.substring(6, 8));
        sb.append(" ").append(time.substring(8, 10)).append(":").append(time.substring(10, 12));
        return sb.toString();
    }
867779
def read_trip_counts_by_date(path: str) -> Dict[datetime.date, int]:
    """"""
    feed = load_raw_feed(path)
    return _trip_counts_by_date(feed)
543574
def GetTimeStops(self):
    """"""
    return [(st.arrival_secs, st.departure_secs, st.stop) for st in
            self.GetStopTimes()]
452425
def get_start_and_end_times(
    feed: "Feed", date: Optional[str] = None
) -> List[str]:
    
    st = feed.get_stop_times(date)
    return (
        st["departure_time"].dropna().min(),
        st["arrival_time"].dropna().max(),
    )
609647
def get_hours_data(self, entries, date_headers):
        """"""
        project_totals = get_project_totals(
            entries, date_headers, total_column=False) if entries else []

        data_map = {}
        for rows, totals in project_totals:
            for user, user_id, periods in rows:
                for period in periods:
                    day = period['day']
                    if day not in data_map:
                        data_map[day] = {'billable': 0, 'nonbillable': 0}
                    data_map[day]['billable'] += period['billable']
                    data_map[day]['nonbillable'] += period['nonbillable']

        return data_map
1357723
def _display(self, sent, now, chunk, mbps):
        
        if self.parent is not None:
            self.parent._display(self.parent.offset + sent, now, chunk, mbps)
            return

        elapsed = now - self.startTime

        if sent > 0 and self.total is not None and sent <= self.total:
            eta = (self.total - sent) * elapsed.total_seconds() / sent
            eta = datetime.timedelta(seconds=eta)
        else:
            eta = None

        self.output.write(
            "\r %s: Sent %s%s%s ETA: %s (%s) %s%20s\r" % (
                elapsed,
                util.humanize(sent),
                "" if self.total is None else " of %s" % (util.humanize(self.total),),
                "" if self.total is None else " (%d%%)" % (int(100 * sent / self.total),),
                eta,
                "" if not mbps else "%.3g Mbps " % (mbps,),
                chunk or "",
                " ",
            )
        )

        self.output.flush()
1016522
def pretty_time(s, granularity=3):
    

    intervals = (
        ('weeks', 604800),  # 60 * 60 * 24 * 7
        ('days', 86400),  # 60 * 60 * 24
        ('hours', 3600),  # 60 * 60
        ('minutes', 60),
        ('seconds', 1),
    )

    def display_time(seconds, granularity=granularity):
        result = []

        for name, count in intervals:
            value = seconds // count
            if value:
                seconds -= value * count
                if value == 1:
                    name = name.rstrip('s')
                result.append('{} {}'.format(int(value), name))

        return ', '.join(result[:granularity])

    return display_time(s, granularity)
331891
def pretty_now():
    """'"""
    import datetime, tzlocal
    time_zone = tzlocal.get_localzone()
    now       = datetime.datetime.now(time_zone)
    return now.strftime("%Y-%m-%d %H:%M:%S %Z%z")
373402
private String humanReadable(long uptime) {
        uptime = uptime / 1000;

        int sec = (int) uptime % 60;
        uptime /= 60;

        int min = (int) uptime % 60;
        uptime /= 60;

        int hour = (int) uptime % 24;
        uptime /= 24;

        int day = (int) uptime;

        String str = "";
        if (day > 0)
            if (day > 1)
                str += day + " days, ";
            else
                str += day + " day, ";
        // prints 0 hour in case days exists. Otherwise prints 2 days, 34 min, sounds weird.
        if (hour > 0 || (day > 0))
            if (hour > 1)
                str += hour + " hours, ";
            else
                str += hour + " hour, ";
        if (min > 0)
            str += min + " min, ";
        if (sec > 0)
            str += sec + " s";

        return str;
    }
691934
def prettyPrintPacket(ctrl_table):
	
	print('---------------------------------------')
	print("{:.<29} {}".format('id', ctrl_table['id']))
	ctrl_table.pop('id')
	for key, value in ctrl_table.items():
		print("{:.<29} {}".format(key, value))
166958
function _cleanResults(results) {

  // Clean up departures
  results = _cleanDepartures(results);

  // Clean up arrivals
  results = _cleanArrivals(results);

  // Sort By Departure Time
  results.sort(TripSearchResult.sortByDeparture);

  // Return results
  return results;


  /**
   * Pick best Trip with equal departures
   * @param results
   * @returns {Array}
   * @private
   */
  function _cleanDepartures(results) {
    // List of Departures to Keep
    let departures = [];

    // Get unique departures
    let departureTimes = [];
    for ( let i = 0; i < results.length; i++ ) {
      if ( departureTimes.indexOf(results[i].origin.departure.toTimestamp()) === -1 ) {
        departureTimes.push(results[i].origin.departure.toTimestamp());
      }
    }

    // Pick best Trip for each departure
    for ( let i = 0; i < departureTimes.length; i++ ) {
      let departureTime = departureTimes[i];
      let departure = undefined;

      // Get Trips with departure time
      for ( let j = 0; j < results.length; j++ ) {
        let result = results[j];
        if ( result.origin.departure.toTimestamp() === departureTime ) {
          if ( departure === undefined )  {
            departure = result;
          }
          else if ( result.destination.arrival.toTimestamp() < departure.destination.arrival.toTimestamp() ) {
            departure = result;
          }
          else if ( result.destination.arrival.toTimestamp() === departure.destination.arrival.toTimestamp() && result.length < departure.length ) {
            departure = result;
          }
        }
      }

      // Add departure to list
      departures.push(departure);
    }

    // Return departures
    return departures;
  }


  /**
   * Pick best Trip with equal arrivals
   * @param results
   * @returns {Array}
   * @private
   */
  function _cleanArrivals(results) {
    // List of Arrivals to Keep
    let arrivals = [];

    // Get unique arrivals
    let arrivalTimes = [];
    for ( let i = 0; i < results.length; i++ ) {
      if ( arrivalTimes.indexOf(results[i].destination.arrival.toTimestamp()) === -1 ) {
        arrivalTimes.push(results[i].destination.arrival.toTimestamp());
      }
    }

    // Pick best Trip for each arrival
    for ( let i = 0; i < arrivalTimes.length; i++ ) {
      let arrivalTime = arrivalTimes[i];
      let arrival = undefined;

      // Get Trips with arrival time
      for ( let j = 0; j < results.length; j++ ) {
        let result = results[j];
        if ( result.destination.arrival.toTimestamp() === arrivalTime ) {
          if ( arrival === undefined )  {
            arrival = result;
          }
          else if ( result.origin.departure.toTimestamp() > arrival.origin.departure.toTimestamp() ) {
            arrival = result;
          }
          else if ( result.origin.departure.toTimestamp() === arrival.origin.departure.toTimestamp() && result.length < arrival.length ) {
            arrival = result;
          }
        }
      }

      // Add arrival to list
      arrivals.push(arrival);

    }

    // Return arrivals
    return arrivals;
  }

}
1196354
def get_time_attr_map(t):
    
    now = datetime.datetime.now()
    if t + datetime.timedelta(hours=3) > now:
        return get_map("main_list_white")
    if t + datetime.timedelta(days=3) > now:
        return get_map("main_list_lg")
    else:
        return get_map("main_list_dg")
763310
def _print_if_needed(self):
        """"""
        if self._in_txn or self.print_frequency is None:
            return
        elif self.last_export is not None and \
             self.last_export + self.print_frequency > time.time():
            return

        self.export()
869628
def pretty_date(the_datetime):
    """"""
    # Source modified from
    # http://stackoverflow.com/a/5164027/176978
    diff = datetime.utcnow() - the_datetime
    if diff.days > 7 or diff.days < 0:
        return the_datetime.strftime('%A %B %d, %Y')
    elif diff.days == 1:
        return '1 day ago'
    elif diff.days > 1:
        return '{0} days ago'.format(diff.days)
    elif diff.seconds <= 1:
        return 'just now'
    elif diff.seconds < 60:
        return '{0} seconds ago'.format(diff.seconds)
    elif diff.seconds < 120:
        return '1 minute ago'
    elif diff.seconds < 3600:
        return '{0} minutes ago'.format(int(round(diff.seconds / 60)))
    elif diff.seconds < 7200:
        return '1 hour ago'
    else:
        return '{0} hours ago'.format(int(round(diff.seconds / 3600)))
185989
function _info() {
    if ( LOG ) {
      let p = "";
      for ( let i = 0; i < segments.length * 2; i++ ) {
        p = p + " ";
      }

      let tripIds = [];
      for ( let i = 0; i < trips.length; i++ ) {
        tripIds.push(trips[i].id);
      }
      _log(p + "Trips From " + enter.name + ": " + trips.length + " ('" + tripIds.join("', '") + "')");

      _log(p + "   Segments: " + segments.length);
      _printSegments(segments, p + "   ");
    }
  }