github.com/googleapis/api-linter@v1.65.2/docs/rules/0142/time-field-type.md (about)

     1  ---
     2  rule:
     3    aip: 142
     4    name: [core, '0142', time-field-type]
     5    summary: Timestamps should use `google.protobuf.Timestamp`.
     6  permalink: /142/time-field-type
     7  redirect_from:
     8    - /0142/time-field-type
     9  ---
    10  
    11  # Timestamp field type
    12  
    13  This rule enforces that timestamps are represented with
    14  `google.protobuf.Timestamp`, as mandated in [AIP-142][].
    15  
    16  ## Details
    17  
    18  This rule looks at each field and looks for common suffixes that indicate that
    19  the field may represent time, and indicates that the
    20  `google.protobuf.Timestamp` type should be used instead.
    21  
    22  ## Examples
    23  
    24  **Incorrect** code for this rule:
    25  
    26  ```proto
    27  // Incorrect.
    28  message Book {
    29    string name = 1;
    30    int32 publish_time_sec = 2;  // Should use `google.protobuf.Timestamp`.
    31  }
    32  ```
    33  
    34  **Correct** code for this rule:
    35  
    36  ```proto
    37  // Correct.
    38  message Book {
    39    string name = 1;
    40    google.protobuf.Timestamp publish_time = 2;
    41  }
    42  ```
    43  
    44  ## Disabling
    45  
    46  If you need to violate this rule, use a leading comment above the method.
    47  Remember to also include an [aip.dev/not-precedent][] comment explaining why.
    48  
    49  ```proto
    50  // (-- api-linter: core::0142::time-field-type=disabled
    51  //     aip.dev/not-precedent: We need to do this because reasons. --)
    52  message Book {
    53    string name = 1;
    54    int32 publish_time_sec = 2;
    55  }
    56  ```
    57  
    58  If you need to violate this rule for an entire file, place the comment at the
    59  top of the file.
    60  
    61  [aip-142]: https://aip.dev/142
    62  [aip.dev/not-precedent]: https://aip.dev/not-precedent