jhalter / mobius

A Hotline server implemented in Golang for macOS, Linux, and Windows operating systems
MIT License
73 stars 8 forks source link

Custom date & time in news not working #65

Closed Knezzen closed 1 year ago

Knezzen commented 1 year ago

Hi!

Trying to format the custom date and time as follows in my configuration file: NewsDateFormat: "%A %B %d %Y at %H:%M"

This renders in the date and time in the news/msg board post being exactly that I put in the configuration file, like: From User123 (%A %B %d %Y at %H:%M):

Am I missing something? This feature is not that documented and I just assumed that the standard unix date and time formats where used.

Thanks for an awesome piece of software btw! Just migrated our System 7 Today Hotline server from hxd and it has been working wonders.

jhalter commented 1 year ago

Hi, the template string format uses a layout string using Golang's "example-based" formatting, which uses a special reference time of Mon Jan 2 15:04:05 MST 2006 to determine the output format.

(I should document this, sorry)

So for example if you were to put this in your config yaml:

NewsDateFormat: "Jan 02 15:04 2006"

You'd get a news date like: Nov 02 13:34 2013

If you used this:

NewsDateFormat: "01/02/2006 15:04"

You'd get 11/02/2013 13:34 2013

There's some more details here: https://yourbasic.org/golang/format-parse-string-time-date-example/

jhalter commented 1 year ago

Also, I love System 7 Today!! 😄

jhalter commented 1 year ago

@Knezzen Looks like you got the news format working based on your news post?

Knezzen commented 1 year ago

@jhalter Yes! Thank you! Issue can be closed :)