3 Replies Latest reply on Sep 6, 2013 2:12 PM by wpurrer

    AF SDK Date Time Issues


      Dear all       


      I have to AF SDK Clients installations => both with Version
      => one Client is in Asia (Asia Time Zone + Language Settings + timezone ) and one in Europe (german time and language settings + timezone)
      Server is: 3.4.390.18




      The server is in asia

      when is use the following command on both clients


      AFValues values = mypoint.RecordedValues(new OSIsoft.AF.Time.AFTimeRange("t-1 year", "t"), OSIsoft.AF.Data.AFBoundaryType.Inside, "", false);


      when i use the one in asia is working, not the one in europa, here i get the following error message


      System.FormatException: The string 't-1 year' was not recognized as a valid Date Time.    at OSIsoft.AF.Time.AFTime.TryParseImpl(String parmName, String input, Nullabl e`1 referenceTime, AFTimeZone timeZone, IFormatProvider provider, Boolean throwE rrors, DateTime& result)    at OSIsoft.AF.Time.AFTime..ctor(String timeString, IFormatProvider provider)    at OSIsoft.AF.Time.AFTimeRange..ctor(String startTime, String endTime, IForma tProvider provider)    at OSIsoft.AF.Time.AFTimeRange..ctor(String startTime, String endTime)    at PIMSSpeedTEst.Program.Main(String[] args)


      (i also tried it with other syntaxes)... always the same error 



        • Re: AF SDK Date Time Issues

          PS when i use


          AFValues values = mypoint.RecordedValues(new OSIsoft.AF.Time.AFTimeRange(DateTime.Now.AddYears(-1),DateTime.Now), OSIsoft.AF.Data.AFBoundaryType.Inside, "", false);


          everything works from both servers

            • Re: AF SDK Date Time Issues
              David Hearn

              When the IFormatProvider is not specified, then only the CurrentCulture is used when parsing the time string. If you use the overload with the IFormatProvider parameter and specify 'null' for the provider, then the current culture will be tried and then the InvariantCulture if that fails. In your case since you are using the invariant strings in both locations, you probably want to just specify 'InvariantCulture' as the provider.


              new AFTimeRange("t-1 year", "t", CultureInfo.InvariantCulture)