!******************************************************************************!
! Test for modifying displayed data format on a plot
!
! @bug      BUG 2753   PLOT: does not display YY:MM:DD on readout=+DATESTRING
! @author:  D Siamons
!******************************************************************************!
startmacro

switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE
switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE

set defaultInstructions &
    "1. Verify the default date format on both readout and axis is YMD ( yyyy:mm:dd ) \n\n&
     2. Select different time formats and verify on readout and axis. \n\n&
     3. Add a valid SimpleDateFormat pattern and enter and verify on readout and axis. \n\n&
     4. Select Auto format and verify that format is displayed as STD and includes the year, month and day.  \n\n&
     5. Zoom in such that time range does not span over two different days (i.e. doesn't include midnight) and verify format is HMS."

if interAct then
  waveform ram:mywave
  timex now date
  headermod ram:mywave XS=^date XD=36

  pipe init
    panel/setup/controls=gc
    gcontrol label mainLabel "Main"
    gcontrol menu main "Exit with Status = " "PASS,FAIL" /tleft
    set gc.main.itemColors {PASS=GREEN,FAIL=RED}
    gcontrol text idtext "Instructions" "^defaultInstructions" 10 20 /title

    gcontrol label formatsLabel "Formats"
    gcontrol/nc=3 button formats "Select Format" "Std,Acq,Epoch,Norad,TCR,Vax,Filename,HMS,YMD,ISO8601,Auto,Default" /ttop
    gcontrol label formatsLabel "SimpleDateFormat Pattern"
    gcontrol prompt prompt1 "Pattern" ""

    plot/msgid=MAIN/id=idplot/readout=+onaxis|+DATESTRING/DATEFORMAT=YMD   ram:mywave
  pipe off

endif

endmacro

!******************************************************************************!
procedure processMessage m:msg
!say "got ^{msg.toString(NAME|DATA)}"

  if msg.name eqs "MAIN" then
    assert/text="^reg.main.name: User indicated tests" msg.data eqss "PASS"
    pipe stop
  elseif msg.name eqs "FORMATS" or  msg.name eqs "PROMPT1"
      set reg.idplot.dateformat "^msg.data"
      invoke reg.idplot.refresh()
  else
    !do nothing
  endif

return
