Gitility.Identity (Gitility v0.3.0)

Copy Markdown View Source

An author or committer identity, preserved exactly as Git encoded it.

name and email are raw bytes — Git makes no encoding promise, and Gitility makes none either. time is Unix seconds; tz is the raw timezone field exactly as encoded (e.g. "+1000", including the -0000 that some tools emit). Log results additionally populate tz_offset_minutes with the parsed numeric offset when the raw field is a valid in-range +HHMM/-HHMM value; Git-tolerated malformed values remain in tz and produce nil rather than failing the log page.

display_name/1 and to_datetime/1 are the lossy conveniences.

Summary

Functions

The name as a printable string (lossy — see Gitility.Path.display/1).

The identity's timestamp as a UTC DateTime.

The identity's UTC offset in seconds, parsed from the raw tz field.

Types

t()

@type t() :: %Gitility.Identity{
  email: binary(),
  name: binary(),
  time: integer(),
  tz: binary(),
  tz_offset_minutes: integer() | nil
}

Functions

display_name(identity)

@spec display_name(t()) :: String.t()

The name as a printable string (lossy — see Gitility.Path.display/1).

to_datetime(identity)

@spec to_datetime(t()) :: {:ok, DateTime.t()} | {:error, Gitility.Error.t()}

The identity's timestamp as a UTC DateTime.

Deliberately UTC-only: representing the original local offset would require inventing a timezone, and -0000 has no integer representation at all. The exact original offset stays available in tz; combine the two when local wall time matters.

utc_offset(identity)

@spec utc_offset(t()) :: {:ok, integer(), boolean()} | {:error, Gitility.Error.t()}

The identity's UTC offset in seconds, parsed from the raw tz field.

Returns {:ok, seconds, negative_zero?}negative_zero? is true for the -0000 encoding some tools emit, which means "offset unknown" rather than UTC.