Gloablization issue "Tick Error" converting datetime

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hemendravyas
    New Member
    • Aug 2007
    • 9

    Gloablization issue "Tick Error" converting datetime

    i m located in India (working as software developer) and working on application that was not used in India (used in UK) but when used outside UK used to give "Tick Error"

    Interface: It's Win Forms of .NET2003 (using framework 1.1)
    Middle Tier: web services using globalization part settings as :
    a) requestEncoding ="UTF-8"
    b) responseEncodin g="UTF-8"
    c) culture="en-GB"
    d) uiculture="en-GB"

    I think this error comes when date time value is parsed from India to UK and vice versa.

    Please suggest some solution and it makes various calles to the middle tier component and complex calculations are done.
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Do you have an example of an actual error message as "Tick Error" does not appear to be an actual exception message.
    Also, do you know what line of code is causing the error?

    Comment

    • hemendravyas
      New Member
      • Aug 2007
      • 9

      #3
      It's caused in middle tier:

      Unhandled Exception: System.Argument OutOfRangeExcep tion: Ticks must be between DateTime.MinVal ue.Ticks and DateTime.MaxVal ue.Ticks. Parameter name: ticks


      the application reaches to middle tier by a web service. From web service there are calls to different files making complex calculations... ...

      First i thought it's due to transfer of data between framework 1.1 and 2.0 as is given in : http://support.microso ft.com/kb/907262

      I tried:
      1. converting time (in India) to UK and do it
      Result: no error

      2. taking Indian time
      Result: tick error

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        "middle-tier" doesn't tell me much since I am unfamiliar with the buzzwords.

        I'm not sure why time conversion would throw any errors as Time is counted in ticks, regardless of what country you are in, it only effects how it is displayed (and possibly the timezone)

        Code:
        System.ArgumentOutOfRangeException: Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. Parameter name: ticks
        This says that somewhere there is a DateTime object that is being creating by ticks (Possibly with "new DateTime(Int64 Ticks)") and it's being fed a number that is not valid.

        I suggest you go find the exact line of code that is causing the error and investigate futher

        Comment

        • hemendravyas
          New Member
          • Aug 2007
          • 9

          #5
          Time zones are different:

          India: GMT+530
          UK: GMT

          will it cause this error?

          It is also causing when the same application is accessed from US to UK.....

          but in UK it's perfectly running fine.....

          Comment

          • hemendravyas
            New Member
            • Aug 2007
            • 9

            #6
            Do we need to take care of any castinf when we are passing data from one timezonre to another?


            By Middle component i mean components (variouscsharp files compiled into dll) lying in UK...which are called by a GUI in India or US or UK....

            Comment

            • Plater
              Recognized Expert Expert
              • Apr 2007
              • 7872

              #7
              Do you have access to the source code?
              The timezone being different should not have any effect.
              It's going to be a ticks values ie either too big (or my guess too small) to create a valid DateTime object.

              Comment

              • hemendravyas
                New Member
                • Aug 2007
                • 9

                #8
                Code:
                [NonSerialized()]
                protected DataView m_dataView;
                
                
                
                public virtual DateTime GetN(IFNAccessor p_ifNReq)
                		{
                			//initialise
                			DateTime dRet = GlobalUtils.NODATE;
                
                			if(p_ifNReq != null)
                			{
                				p_ifNReq.N = Double.NaN;
                
                				if(m_dataView == null)
                					CreateView( );
                				
                								bool bContinue = true;
                				DateTime valDate = p_ifNReq.ValDate;
                				DateTime stopDate = new DateTime(1,1,1);
                
                				while(bContinue)
                				{
                					DataRowView[] drVArr = m_dataView.FindRows(valDate);
                					if((drVArr != null) && (drVArr.Length > 0))
                					{
                						p_ifNReq.N = (double)drVArr[0].Row["N"];
                						dRet = (DateTime)drVArr[0].Row[m_strValDate];
                						bContinue = false;
                					}
                
                					if(bContinue == true)
                					{
                						if ( valDate.CompareTo( stopDate ) == 0 )
                							break;
                
                						//decrement Valdate by one day
                						valDate = valDate.AddDays(-1);
                					}
                				}//while loop
                
                				if(bContinue == true)
                				{
                										FTraceLog.WriteLog(TraceLevel.Error, "No data found for valDate = ", p_ifNReq.ValDate.ToShortDateString( ) );					
                				}
                	
                			}
                			return dRet;
                		}



                In the above line of code when the application is accessed from India it has "Null" value for "drVArr"

                if((drVArr != null) && (drVArr.Length > 0))

                so it never enters into the "if " block.

                Is it something related to serialization of Time????

                Pls. help...

                Comment

                • Plater
                  Recognized Expert Expert
                  • Apr 2007
                  • 7872

                  #9
                  It would seem that it does not find any rows in your row view that match that datetime criteria.
                  If you are worried about their being differences in datetime's, use UTC datetime to store everything, and when you create you "local" datetime, tell it that it's coming from a UTC datetime, then it will automatically know how to convert it to the correct local timezone.


                  Also:
                  new DateTime(1,1,1)

                  Might be better off as:
                  DateTime.MinVal ue

                  Comment

                  • hemendravyas
                    New Member
                    • Aug 2007
                    • 9

                    #10
                    no not able to track


                    and why will it show error only when we access from India or US and not from UK???
                    it might be time serailization.. ...

                    Comment

                    • Plater
                      Recognized Expert Expert
                      • Apr 2007
                      • 7872

                      #11
                      well if you're always using "local time" the times in the datatable might be "1100" and not your timezone difference say "0900" so it finds no matches and never enters into the IF statement.
                      Debug up to there and look at what datetime you're searching for, and what datetimes are kept in the datatable

                      Comment

                      Working...