Make convert_timestamp public?

9 views
Skip to first unread message

honeyry...@gmail.com

unread,
Dec 3, 2021, 7:04:18 AM12/3/21
to Rodauth
Hi Jeremy,

I'm coming from a recent issue report on rodauth-oauth (https://gitlab.com/honeyryderchuck/rodauth-oauth/-/issues/38) where a user example broke because I'm using "rodauth.convert_timestamp" in the html templates. It being a private method, makes sense (I don't remember how I came to use it in the first place).

That being said, seems that this method could have some use outside of rodauth, namely to convert-and-display time instances from the db. Is that a fair assumption, or should I be using something else for that effect?

Thx,
Tiago

Jeremy Evans

unread,
Dec 3, 2021, 11:19:13 AM12/3/21
to rod...@googlegroups.com
The convert_timestamp is private because it's designed for internal use.  I don't really want to make it public, as that limits my ability to change it in the future (no such changes are planned or expected, though).  If you want to use it publicly in rodauth-oath, I would override the method in your rodauth feature using a public method, then call super.

Thanks,
Jeremy

honeyry...@gmail.com

unread,
Dec 3, 2021, 1:08:45 PM12/3/21
to Rodauth
Definitely an option. However, given that the use reported in the issue is on a basic CRUD html page where the list of resources is shown (where date of creation is shown), is there a more sequel-standard way to convert timestamps to "human-readable" for page display, or would you stand by your first suggestion?

Jeremy Evans

unread,
Dec 3, 2021, 2:03:53 PM12/3/21
to rod...@googlegroups.com
On Fri, Dec 3, 2021 at 10:08 AM honeyry...@gmail.com <honeyry...@gmail.com> wrote:
Definitely an option. However, given that the use reported in the issue is on a basic CRUD html page where the list of resources is shown (where date of creation is shown), is there a more sequel-standard way to convert timestamps to "human-readable" for page display, or would you stand by your first suggestion?

Well, convert_timestamp isn't for converting timestamps to human readable format.  It's only purpose in Rodauth is to handle timestamps returned as strings by the database, and jdbc-sqlite is the only Sequel database driver that needs it (other databases return timestamps as Time objects).  So if you are using convert_timestamp for human-readable display, you should remove it and use the argument you were passing to it directly.

Thanks,
Jeremy

honeyry...@gmail.com

unread,
Dec 4, 2021, 10:23:32 AM12/4/21
to Rodauth
gotcha, makes sense. Will refrain from using it then.

Thanks
Reply all
Reply to author
Forward
0 new messages