(self)
return result + '.%09dZ' % nanos
Converts Timestamp to RFC 3339 date string format.

    Returns:
      A string converted from timestamp. The string is always Z-normalized
      and uses 3, 6 or 9 fractional digits as required to represent the
      exact time. Example of the return format: '1972-01-01T10:00:20.021Z'
Converts Timestamp to RFC 3339 date string format.
Converts Timestamp to RFC 3339 date string format .
def ToJsonString(self):
    """Converts Timestamp to RFC 3339 date string format.

    Returns:
      A string converted from timestamp. The string is always Z-normalized
      and uses 3, 6 or 9 fractional digits as required to represent the
      exact time. Example of the return format: '1972-01-01T10:00:20.021Z'
    """
    nanos = self.nanos % _NANOS_PER_SECOND
    total_sec = self.seconds + (self.nanos - nanos) // _NANOS_PER_SECOND
    seconds = total_sec % _SECONDS_PER_DAY
    days = (total_sec - seconds) // _SECONDS_PER_DAY
    dt = datetime(1970, 1, 1) + timedelta(days, seconds)

    result = dt.isoformat()
    if (nanos % 1e9) == 0:
      # If there are 0 fractional digits, the fractional
      # point '.' should be omitted when serializing.
      return result + 'Z'
    if (nanos % 1e6) == 0:
      # Serialize 3 fractional digits.
      return result + '.%03dZ' % (nanos / 1e6)
    if (nanos % 1e3) == 0:
      # Serialize 6 fractional digits.
      return result + '.%06dZ' % (nanos / 1e3)
    # Serialize 9 fractional digits.
    return result + '.%09dZ' % nanos
def ToJsonString ( self ) : nanos = self . nanos % _NANOS_PER_SECOND total_sec = self . seconds + ( self . nanos - nanos ) // _NANOS_PER_SECOND seconds = total_sec % _SECONDS_PER_DAY days = ( total_sec - seconds ) // _SECONDS_PER_DAY dt = datetime ( 1970 , 1 , 1 ) + timedelta ( days , seconds ) result = dt . isoformat ( ) if ( nanos % 1e9 ) == 0 : # If there are 0 fractional digits, the fractional # point '.' should be omitted when serializing. return result + 'Z' if ( nanos % 1e6 ) == 0 : # Serialize 3 fractional digits. return result + '.%03dZ' % ( nanos / 1e6 ) if ( nanos % 1e3 ) == 0 : # Serialize 6 fractional digits. return result + '.%06dZ' % ( nanos / 1e3 ) # Serialize 9 fractional digits. return result + '.%09dZ' % nanos