newLISP Fan Club

Forum => newLISP in the real world => Topic started by: hs on October 02, 2009, 08:05:37 PM

Title: suppresing zero in date with # doesn't work in openbsd
Post by: hs on October 02, 2009, 08:05:37 PM
> (date (date-value) 0 "%a %#d %b %Y")

"Sat #d Oct 2009"

> (date (date-value) 0 "%a %-d %b %Y")

"Sat -d Oct 2009"

> (date (date-value) 0 "%A %-d. %B %Y")

"Saturday -d. October 2009"



newlisp 10.1.5 on OpenBSD 4.5
Title:
Post by: cormullion on October 03, 2009, 01:00:07 AM
Doesn't seem to work on MacOS X either. But you can use %e for the day of the month:


(date (date-value) 0 "%a %e %b %Y")
;-> "Sat  3 Oct 2009"
Title:
Post by: Lutz on October 03, 2009, 05:09:53 AM
It works on Win32 using "%#d" and on FreeBSD and UBUNTU Linux using "%-d" as written in the manual. On OpenBSD, SunOS/Solaris and Mac OS X use the "%e" as shown by cormullion.



newLISP internally uses the C function strftime() for formatting dates. The format characters offered on different platforms differ. Use "man strftime" on Unix platforms to consult the man page for your implementation.



The newLISP manual only shows formatting characters found on all platforms. There are many more format characters and platform/locale specific extensions. Here a link to a typical Unix man page:



http://opengroup.org/onlinepubs/007908775/xsh/strftime.html



I will add the "%e" form to the manual as it seems to be popular on Unixes.