Android Question How to use PrettyTime Library?

Meigionel TS

Member
Licensed User
I was trying to use the PrettyTime Library by Don but could not understand how it works.

There is an example in the library page which I tried and got a strange result. Here is what I tried:

B4X:
Dim fromSql as String = "2019-09-08 16:33:16"
Dim getDateTime() as String = Regex.Split(" ",fromSql)

Dim date as String = getDateTime(0)
Dim time as String = getDateTime(1)
DateTime.DateFormat = "yyyy-mm-dd"
DateTime.TimeFormat = "kk:mm:ss"

Dim DateTimeLong As Long = DateTime.DateTimeParse(date,time)
Log(prettytime.format(DateTimeLong))
Now the date I have given is of yesterday that is "2019-09-08" but when I checked the log for the prettytime library's return it says "8 months ago" even when it should have said "yesterday". It is a very interesting library but I could not find proper documentation for all the functions of the library. If someone could help me out, I will be really thankful. :)
 

Meigionel TS

Member
Licensed User
After banging my head against the wall since this morning, I realize I have been using "yyyy-mm-dd" instead of "yyyy-MM-dd". *facepalm*
 
Top