Changing time UTC

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bed
    Junior Member
    • Jun 2017
    • 8

    #16
    I am specifying AUS races but I get an no response/errror. I spoke to betfair about this and they advised me "It looks like the time you’re passing in is UTC; not local time. If you change to that; you’ll get runners.
    Therefore, I have been trying to change the time...

    Is this what you're after...?

    Private Sub ListMarketCatalogue()

    Dim requestList As New List(Of MarketCatalogueRequest)
    Dim request As New MarketCatalogueRequest
    Dim params As New Params

    Dim eventTypeIds As New List(Of String)
    eventTypeIds.Add("7")
    params.filter.eventTypeIds = eventTypeIds

    Dim marketCountries As New List(Of String)
    marketCountries.Add("AU")
    params.filter.marketCountries = marketCountries

    Dim marketProjection As New List(Of String)
    marketProjection.Add("MARKET_START_TIME")
    marketProjection.Add("RUNNER_DESCRIPTION")
    marketProjection.Add("EVENT")
    params.marketProjection = marketProjection

    Dim marketTypeCodes As New List(Of String)
    marketTypeCodes.Add("WIN")
    params.filter.marketTypeCodes = marketTypeCodes

    Dim marketStartTime As New StartTime

    If Today.IsDaylightSavingTime() Then

    marketStartTime.from = Format(Date.Now, "yyyy-MM-dd") & "T" & Format(Now.AddHours(-1), "HH:mm") & "Z"

    Else

    marketStartTime.from = Format(Date.Now, "yyyy-MM-dd") & "T" & Format(Now.AddHours(-6), "HH:mm") & "Z"

    End If

    marketStartTime.to = Today.ToString("u").Replace(" ", "T").Replace("00:00", "23:00")
    params.filter.marketStartTime = marketStartTime

    request.params = params
    requestList.Add(request)

    Comment

    • only1jake
      Junior Member
      • Nov 2016
      • 29

      #17
      I was just a little confused in what you were requesting!!
      So you are requesting the AU races within a time range.

      I believe all the marketStartTime's are in UTC time as thats what Befair uses. So your time range should be UTC?

      ie. you can do
      marketStartTime.from = Format(Now.addhours(-1).ToUniversalTime, "yyyy-MM-dd") & "T" & Format(Now.addhours(-1).ToUniversalTime, "HH:mm") & "Z"

      I'm not 100% sure as I dont select markets by start time through MarketFilter but I believe it should be UTC time and what Betfair have told you might be incorrect?

      This is what I send off: "{""jsonrpc"": ""2.0"",""method"": ""SportsAPING/v1.0/listMarketCatalogue"",""params"": {""filter"": {""marketCountries"": [""NZ"", ""AU"", ""GB"", ""SG""], ""eventTypeIds"": [""7"",""4339""], ""marketTypeCodes"": [""WIN""]}, ""maxResults"": ""600"", ""marketProjection"": [""MARKET_START_TIME"", ""EVENT_TYPE""], ""MarketSort"": [""FIRST_TO_START""]}, ""id"": 1}"

      Do you include all the parameters? Like Max Results?


      Kind of like JABE said:

      Originally posted by betdynamics View Post
      To convert a local time to UTC (in VB.Net), you can use the .ToUniversalTime() method.

      For example:

      'Local Time
      Dim getDate As DateTime = Now()

      'Universal Time
      Dim utcDate As DateTime = Now().ToUniversalTime()

      If you just want to find the current time in UTC, then you can use DateTime.UtcNow

      For example:

      Dim saveUtcNow As DateTime = DateTime.UtcNow

      This works wherever you are in the world as long as your copy of Windows is set to the correct local timezone/time.

      No need to fiddle with BST, etc as Windows automatically knows about Daylight Saving Time.
      Last edited by only1jake; 07-06-2017, 03:46 AM.

      Comment

      • Bed
        Junior Member
        • Jun 2017
        • 8

        #18
        Thanks again mate.

        So how can I just request AU races with no time filter? At present if I take ' out the time filters ie from "If Today.IsDaylightSavingTime() Then.." then why does my result begin at R2 Sandown which is over an hour away and not at R1 in 15 mins?

        Comment

        • only1jake
          Junior Member
          • Nov 2016
          • 29

          #19
          I'm not too sure why that is, is your time on your computer set to the correct TimeZone? Otherwise if you know for sure there is a certain time difference like daylight savings as you have coded in, could you add that in manually to test?

          I just request all the available markets that are currently open. I just have "marketCountries"", ""eventTypeIds"", ""marketTypeCodes"" in filter. And I add in ""MarketSort"": [""FIRST_TO_START""] after marketprojection to give me all the available races for your chosen country and types ordered by time.

          Comment

          • Bed
            Junior Member
            • Jun 2017
            • 8

            #20
            Thanks again. My time is in Adelaide SA time zone.

            I have similar filters to you. I have included code below. Not sure if you can see any errors. Could it be that my time should be 1 hour back? But we are not in daylight saving... However, Sandown races are half an hour in front of my time... Would that have something to do with it?

            Private Sub ListMarketCatalogue()

            Dim requestList As New List(Of MarketCatalogueRequest)
            Dim request As New MarketCatalogueRequest
            Dim params As New Params

            Dim eventTypeIds As New List(Of String)
            eventTypeIds.Add("7")
            params.filter.eventTypeIds = eventTypeIds

            Dim marketCountries As New List(Of String)
            marketCountries.Add("AU")
            params.filter.marketCountries = marketCountries

            Dim marketProjection As New List(Of String)
            marketProjection.Add("MARKET_START_TIME")
            marketProjection.Add("RUNNER_DESCRIPTION")
            marketProjection.Add("EVENT")
            params.marketProjection = marketProjection

            Dim marketTypeCodes As New List(Of String)
            marketTypeCodes.Add("WIN")
            params.filter.marketTypeCodes = marketTypeCodes

            Dim marketStartTime As New StartTime

            ' If Today.IsDaylightSavingTime() Then

            ' marketStartTime.from = Format(Date.Now, "yyyy-MM-dd") & "T" & Format(Now.AddHours(-1), "HH:mm") & "Z"

            'Else

            'marketStartTime.from = Format(Date.Now, "yyyy-MM-dd") & "T" & Format(Now.AddHours(-6), "HH:mm") & "Z"

            'End If

            'marketStartTime.to = Today.ToString("u").Replace(" ", "T").Replace("00:00", "23:00")
            'params.filter.marketStartTime = marketStartTime

            request.params = params
            requestList.Add(request)

            Dim allMarkets() As MarketCatalogueResponse

            allMarkets = DeserializeMarketCatalogueResponse(SerializeMarket CatalogueRequest(requestList))

            For n = 0 To allMarkets(0).result.Count - 1

            For m = 0 To allMarkets(0).result(n).runners.Count - 1
            Dim course() As String
            course = Split(allMarkets(0).result(n).event.name)

            Comment

            • Bed
              Junior Member
              • Jun 2017
              • 8

              #21
              I think I've done it! At moment all seems to work OK and races in correct order... Thanks for everyone's help!

              Comment

              • only1jake
                Junior Member
                • Nov 2016
                • 29

                #22
                Good to hear! Gets a bit annoying sometimes!!

                I was just going to say that it could be because its not recognizing the timezone correctly and going to a different Aussie timezone. And that you could specify what timezone it is and convert it to UTC from there! But glad you're all sorted!

                https://stackoverflow.com/questions/...local-timezone

                Comment

                Working...
                X