Quintiq file version 2.0
#parent: #root
Method ShowTimeZoneWarning (
  internal[Image] imgWarning_i,
  TimeZone calendarTimezone_i,
  Boolean isForEvent_i
) id:Method_LibCal_GlobalState_ShowTimeZoneWarning
{
  #keys: '[146730.0.1172028286]'
  Body:
  [*
    // Only show when running in timezone-mode.
    visible := TimeZone::HasTimeZoneSupport();
    
    if( visible )
    {
      // Only show the warning when the timezone-offset of the calendar is different from the
      // offset of the local timezone of the Client.
      calendarOffset := calendarTimezone_i.RawOffset();
      localTimezone  := LibCal_GlobalState.GetLocalTimeZone();
      localOffset    := localTimezone.RawOffset();
      
      visible := localOffset <> calendarOffset;
      
      if( visible )
      {
        calendarOffsetAsString := "GMT" + ifexpr( calendarOffset >= Duration::Zero(), "+", "" ) + calendarTimezone_i.RawOffset().Format( "h2:m" );
        localOffsetAsString    := "GMT" + ifexpr( localOffset    >= Duration::Zero(), "+", "" ) + localTimezone     .RawOffset().Format( "h2:m" );
        
        if( isForEvent_i )
        {
          imgWarning_i.Tooltip( Translations::Timezone_WarningEvent( calendarTimezone_i.ID(), calendarOffsetAsString,
                                                                     localTimezone.ID(), localOffsetAsString ) );
        }
        else
        {
          imgWarning_i.Tooltip( Translations::Timezone_WarningSettings( calendarTimezone_i.ID(), calendarOffsetAsString,
                                                                        localTimezone.ID(), localOffsetAsString ) );
        }    
      }
    }
      
    imgWarning_i.Visible( visible );
  *]
}
