anchor.diff:                       <<$P,R/binary>> ->
                           {'+', <<R/binary>>}
                       end,
  -   _ = if Bin1 == <<>> ->
  -             ?err('FORG0001');
  -          true ->
  -             ok
  -       end,          
  -   [DayPart,TimePart] = case binary:split(Bin1,<<"T">>) of
  -                           [_D,<<>>] ->
  -                              ?err('FORG0001'); % T alone should throw error
  -                           [D,T] ->
  -                              [D,T];
  -                           [D] ->
  -                              [D,<<>>]
  -                        end,
  +   {DayPart,TimePart} = get_day_time_parts(Bin1),
      {Year,Mon,Rest} = if DayPart == <<>> ->
                              {0,0,<<>>};
                           true ->
  
positive.code:    BIType = xqerl_btypes:get_type(IType),
     BTType = xqerl_btypes:get_type(TType),
     xqerl_btypes:can_substitute(BIType, BTType).
  
  get_type(#xqSeqType{type = Type}) ->
     get_type(Type);
  
negative.code:                            second = xqerl_numeric:decimal(0), 
                             offset = Offset},
           Str = xqerl_datetime:to_string(Rec,'xs:gDay'),
           ?xav('xs:gDay', set_date_string(Rec, Str));
           true ->
              throw({error,bad_date})
        end
  