Skip to content

Instantly share code, notes, and snippets.

@talentdeficit
Created October 27, 2016 19:10
Show Gist options
  • Save talentdeficit/8c8130630999561796ee01a3f0cbb311 to your computer and use it in GitHub Desktop.
Save talentdeficit/8c8130630999561796ee01a3f0cbb311 to your computer and use it in GitHub Desktop.
iex(5)> dates = [DateTime.from_unix!(100000000), DateTime.from_unix!(100000)] [%DateTime{calendar: Calendar.ISO, day: 3, hour: 9, microsecond: {0, 0},
minute: 46, month: 3, second: 40, std_offset: 0, time_zone: "Etc/UTC",
utc_offset: 0, year: 1973, zone_abbr: "UTC"},
%DateTime{calendar: Calendar.ISO, day: 2, hour: 3, microsecond: {0, 0},
minute: 46, month: 1, second: 40, std_offset: 0, time_zone: "Etc/UTC",
utc_offset: 0, year: 1970, zone_abbr: "UTC"}]
iex(6)> Enum.sort(dates)
[%DateTime{calendar: Calendar.ISO, day: 2, hour: 3, microsecond: {0, 0},
minute: 46, month: 1, second: 40, std_offset: 0, time_zone: "Etc/UTC",
utc_offset: 0, year: 1970, zone_abbr: "UTC"},
%DateTime{calendar: Calendar.ISO, day: 3, hour: 9, microsecond: {0, 0},
minute: 46, month: 3, second: 40, std_offset: 0, time_zone: "Etc/UTC",
utc_offset: 0, year: 1973, zone_abbr: "UTC"}]
iex(7)> dates = [DateTime.from_unix!(100000000), DateTime.from_unix!(300000)]
[%DateTime{calendar: Calendar.ISO, day: 3, hour: 9, microsecond: {0, 0},
minute: 46, month: 3, second: 40, std_offset: 0, time_zone: "Etc/UTC",
utc_offset: 0, year: 1973, zone_abbr: "UTC"},
%DateTime{calendar: Calendar.ISO, day: 4, hour: 11, microsecond: {0, 0},
minute: 20, month: 1, second: 0, std_offset: 0, time_zone: "Etc/UTC",
utc_offset: 0, year: 1970, zone_abbr: "UTC"}]
iex(8)> Enum.sort(dates)
[%DateTime{calendar: Calendar.ISO, day: 3, hour: 9, microsecond: {0, 0},
minute: 46, month: 3, second: 40, std_offset: 0, time_zone: "Etc/UTC",
utc_offset: 0, year: 1973, zone_abbr: "UTC"},
%DateTime{calendar: Calendar.ISO, day: 4, hour: 11, microsecond: {0, 0},
minute: 20, month: 1, second: 0, std_offset: 0, time_zone: "Etc/UTC",
utc_offset: 0, year: 1970, zone_abbr: "UTC"}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment