;+
function nrlanytim2utc,inp0,_EXTRA=_extra
; $Id: nrlanytim2utc.pro,v 1.10 2025/10/08 17:20:39 nathan Exp $
;
; NAME:
;	NRLanytim2utc
;
; PURPOSE:
;	This is an extension of anytim2utc.pro to include yymmdd format and YY-DOY- (ITOS) format
;	and YYYYDOY.HHMMSSFFF (GOES) format
;
; CATEGORY: UTIL time gen string
;
; CALLING SEQUENCE:
;	Result = NRLanytim2utc(inp)
;
; INPUTS:
;	inp:	Any time format accepted by anytim2utc.pro, PLUS yymmdd_hhmmss format
;
; OPTIONAL KEYWORDS:
;	Passed to anytim2utc
;
; OUTPUTS:
;	This function returns a CDS structure (see $SSW/gen/idl/time)
;
; CALLS:    yymmdd2utc.pro, anytim2utc.pro
;
; MODIFICATION HISTORY:
; 	Written by:	N.Rich, 7/2009
;
; $Log: nrlanytim2utc.pro,v $
; Revision 1.10  2025/10/08 17:20:39  nathan
; fix variable ST undefined error
;
; Revision 1.9  2024/08/26 20:50:00  nathan
; typo
;
; Revision 1.8  2024/08/26 20:47:04  nathan
; parameterize for array input and accept GOESR/CASSIE time format
;
; Revision 1.7  2024/08/26 20:31:17  nathan
; parameterize for array input and accept GOESR/CASSIE time format
;
; Revision 1.6  2020/11/13 22:57:16  nathan
; fix for doy case
;
; Revision 1.5  2020/09/04 16:26:04  nathan
; works also for APL timeline format
;
; Revision 1.4  2020/03/31 21:08:58  nathan
; Fixed bug in ITOS format recognition
;
; Revision 1.3  2016/11/30 21:21:45  nathan
; input YY-DOY (ITOS) format
;
; Revision 1.2  2011/02/01 19:50:10  nathan
; be sure to use _extra
;
; Revision 1.1  2009/07/29 21:43:20  nathan
; born
;
;-
dtin=datatype(inp0)

IF dtin NE 'STR' THEN return,anytim2utc(inp0,_EXTRA=_extra)

inp=inp0

IF strpos(inp[0],':') LT 0 and strpos(inp[0],'/') LT 0 and strpos(inp[0],'-') LT 0 and $
   strpos(inp[0],'.') LT 0 THEN return, yymmdd2utc(inp,_EXTRA=_extra)

xx = strsplit(inp[0],'-/:Tt. ',count=c, length=len)
nxx=n_elements(st)

; Check for YYYY-MM-DD
IF len[0] eq 4 and len[1] eq 2 THEN return, anytim2utc(inp,_EXTRA=_extra)

; Check for YY-DOY-hh:mm:ss (ITOS) format
;21-261-01:13:58.405
IF (len[1] eq 3 and c EQ 6) THEN BEGIN
	st = xx
	en = len
ENDIF ELSE BEGIN
; Check for YYYYDOY.HHMMSSFFF (GOES) format
;2024227.030039826
	xx = strsplit(inp[0],'.',count=c,length=len)
	IF (len[0] eq 7 and len[1] eq 9) THEN BEGIN
		st =[0,4,8,10,12,14]
		en =[4,3,2,2,2,3]
	ENDIF
ENDELSE

inp = strmid(inp,st[0],en[0]) + '-' + strmid(inp,st[1],en[1]) + $
    'T' + strmid(inp,st[2],en[2]) + ':' + strmid(inp,st[3],en[3]) + ':' + strmid(inp,st[4],en[4]) + $
    '.' + strmid(inp,st[5],en[5])
;

return,anytim2utc(inp,_EXTRA=_extra)

END
