OT: convert Convergence Time

This topic contains 1 reply, has 2 voices, and was last updated by  Curtis Smith 3 months, 2 weeks ago.

  • Author
    Posts
  • #78593

    Jeff Taylor
    Participant

    Sorry about the off topic but can anyone advise how I could convert (with powershell!) this Convergence Time value for AD repl?

    PT13M14.1445641S

    thanks

  • #78605

    Curtis Smith
    Participant

    Hi Jeff, it would help if you explain how you got this time value and what the parts represent. Taking a wild guess I'm thinking 13 minutes, 14 seconds, 1445641 10 millionths of a second. I assume you mean convert it into a timespan, but you really did not say what you wanted to convert it into.

    You could do something like this.

    $timestamp = "PT13M14.1445641S"
    (Select-String -InputObject $timestamp -Pattern "^(\d*?)PT(\d*?)M(\d*?)\.(\d*?)S$").Matches |
    ForEach-Object {
        [System.TimeSpan]::FromMinutes($_.Groups[2].value) +
        [System.TimeSpan]::FromSeconds($_.Groups[3].value) +
        [System.TimeSpan]::FromMilliseconds([math]::Round($_.Groups[4].value/10000))
    }

You must be logged in to reply to this topic.