\ 4tH library - Logtime formatter - Copyright 2012 J.L. Bezemer
\ You can redistribute this file and/or modify it under
\ the terms of the GNU General Public License

[UNDEFINED] .logtime [IF]
[UNDEFINED] today    [IF] include lib/time.4th [THEN]

21 string (logtime)                    \ buffer for logtime string
                                       \ returns 3 character month
create month-string                    ( n1 -- a n2)
  ," Jan"
  ," Feb"
  ," Mar"
  ," Apr"
  ," May"
  ," Jun"
  ," Jul"
  ," Aug"
  ," Sep"
  ," Oct"
  ," Nov"
  ," Dec"
does> swap 1 max 12 min 1- cells + @c count ;
                                       \ initializes date format
: init-logdate                         ( --)
  today swap month-string (logtime) place
  swap 10000 * + <# # # # # bl hold # # bl hold #> (logtime) +place
;                                      \ get date and format it
                                       \ initializes date and time format
: init-logtime                         ( --)
  init-logdate now 10000 * swap 100 * + +
  <# # # [char] : hold # # [char] : hold # # bl hold #> (logtime) +place
;                                      \ get time, format it and add to date

: logtime (logtime) count ;            ( -- a n)
: .logtime logtime type ;              ( --)

[DEFINED] 4TH# [IF]
  hide (logtime)
[THEN]
[THEN]
