Beispiel #1
0
  def test_timesince(self):
    assert_equal(timesince(datetime.datetime.fromtimestamp(0), datetime.datetime.fromtimestamp(1000)), "16 minutes, 40 seconds")
    assert_equal(timesince(datetime.datetime.fromtimestamp(0), datetime.datetime.fromtimestamp(60)), "1 minute")
    assert_equal(timesince(datetime.datetime.fromtimestamp(0), datetime.datetime.fromtimestamp(1)), "1 second")
    assert_equal(timesince(datetime.datetime.fromtimestamp(0), datetime.datetime.fromtimestamp(2)), "2 seconds")
    assert_equal(timesince(datetime.datetime.fromtimestamp(0), datetime.datetime.fromtimestamp(10000)), "2 hours, 46 minutes")

    assert_equal(timesince(datetime.datetime.fromtimestamp(0), datetime.datetime.fromtimestamp(1000), abbreviate=True), "16m, 40s")
    assert_equal(timesince(datetime.datetime.fromtimestamp(0), datetime.datetime.fromtimestamp(60), abbreviate=True), "1m")
    assert_equal(timesince(datetime.datetime.fromtimestamp(0), datetime.datetime.fromtimestamp(1), abbreviate=True), "1s")
    assert_equal(timesince(datetime.datetime.fromtimestamp(0), datetime.datetime.fromtimestamp(2), abbreviate=True), "2s")
    assert_equal(timesince(datetime.datetime.fromtimestamp(0), datetime.datetime.fromtimestamp(10000), abbreviate=True), "2h, 46m")
Beispiel #2
0
  def test_timesince(self):
    assert_equal(timesince(datetime.datetime.fromtimestamp(0), datetime.datetime.fromtimestamp(1000)), "16 minutes, 40 seconds")
    assert_equal(timesince(datetime.datetime.fromtimestamp(0), datetime.datetime.fromtimestamp(60)), "1 minute")
    assert_equal(timesince(datetime.datetime.fromtimestamp(0), datetime.datetime.fromtimestamp(1)), "1 second")
    assert_equal(timesince(datetime.datetime.fromtimestamp(0), datetime.datetime.fromtimestamp(2)), "2 seconds")
    assert_equal(timesince(datetime.datetime.fromtimestamp(0), datetime.datetime.fromtimestamp(10000)), "2 hours, 46 minutes")

    assert_equal(timesince(datetime.datetime.fromtimestamp(0), datetime.datetime.fromtimestamp(1000), abbreviate=True), "16m, 40s")
    assert_equal(timesince(datetime.datetime.fromtimestamp(0), datetime.datetime.fromtimestamp(60), abbreviate=True), "1m")
    assert_equal(timesince(datetime.datetime.fromtimestamp(0), datetime.datetime.fromtimestamp(1), abbreviate=True), "1s")
    assert_equal(timesince(datetime.datetime.fromtimestamp(0), datetime.datetime.fromtimestamp(2), abbreviate=True), "2s")
    assert_equal(timesince(datetime.datetime.fromtimestamp(0), datetime.datetime.fromtimestamp(10000), abbreviate=True), "2h, 46m")