Last active
August 29, 2015 14:19
-
-
Save Vidarls/5dde8c9b6b8c9f7e5f8c to your computer and use it in GitHub Desktop.
Meetup code 16 April 2015
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({Start = 11.05.2010 21:00:00; | |
End = 12.05.2010 08:00:00;}, | |
[12.05.2010 00:57:09; 12.05.2010 00:57:38; 12.05.2010 00:57:40; | |
12.05.2010 00:57:41; 12.05.2010 01:00:57; 12.05.2010 01:31:05], | |
[03:57:09; 00:00:29; 00:00:02; 00:00:01; 00:03:16; 00:30:08; 06:28:55]) | |
({Start = 16.05.2010 21:00:00; | |
End = 17.05.2010 08:00:00;}, [17.05.2010 02:11:24], [05:11:24; 05:48:36]) | |
({Start = 26.05.2010 21:00:00; | |
End = 27.05.2010 08:00:00;}, | |
[27.05.2010 01:49:02; 27.05.2010 01:50:41; 27.05.2010 02:19:24], | |
[04:49:02; 00:01:39; 00:28:43; 05:40:36]) | |
({Start = 01.06.2010 21:00:00; | |
End = 02.06.2010 08:00:00;}, | |
[01.06.2010 22:53:47; 01.06.2010 23:55:07; 02.06.2010 00:17:40; | |
02.06.2010 01:27:53; 02.06.2010 01:32:52; 02.06.2010 01:36:47], | |
[01:53:47; 01:01:20; 00:22:33; 01:10:13; 00:04:59; 00:03:55; 06:23:13]) | |
({Start = 06.06.2010 21:00:00; | |
End = 07.06.2010 08:00:00;}, | |
[06.06.2010 23:43:28; 07.06.2010 00:34:20; 07.06.2010 00:36:17; | |
07.06.2010 00:38:52; 07.06.2010 00:56:47; 07.06.2010 00:56:54; | |
07.06.2010 01:05:51; 07.06.2010 01:13:17], | |
[02:43:28; 00:50:52; 00:01:57; 00:02:35; 00:17:55; 00:00:07; 00:08:57; 00:07:26; | |
06:46:43]) | |
({Start = 22.06.2010 21:00:00; | |
End = 23.06.2010 08:00:00;}, [23.06.2010 00:11:27; 23.06.2010 01:08:22], | |
[03:11:27; 00:56:55; 06:51:38]) | |
({Start = 27.06.2010 21:00:00; | |
End = 28.06.2010 08:00:00;}, | |
[28.06.2010 03:34:34; 28.06.2010 03:34:45; 28.06.2010 04:01:01; | |
28.06.2010 04:01:10], [06:34:34; 00:00:11; 00:26:16; 00:00:09; 03:58:50]) | |
({Start = 04.07.2010 21:00:00; | |
End = 05.07.2010 08:00:00;}, | |
[04.07.2010 23:34:24; 05.07.2010 01:25:13; 05.07.2010 02:07:58], | |
[02:34:24; 01:50:49; 00:42:45; 05:52:02]) | |
({Start = 20.09.2010 21:00:00; | |
End = 21.09.2010 08:00:00;}, [21.09.2010 01:09:36; 21.09.2010 01:17:26], | |
[04:09:36; 00:07:50; 06:42:34]) | |
({Start = 24.09.2010 21:00:00; | |
End = 25.09.2010 08:00:00;}, [25.09.2010 01:13:46], [04:13:46; 06:46:14]) | |
({Start = 01.10.2010 21:00:00; | |
End = 02.10.2010 08:00:00;}, | |
[02.10.2010 00:49:40; 02.10.2010 00:49:41; 02.10.2010 01:50:59], | |
[03:49:40; 00:00:01; 01:01:18; 06:09:01]) | |
({Start = 07.10.2010 21:00:00; | |
End = 08.10.2010 08:00:00;}, | |
[07.10.2010 22:53:43; 08.10.2010 01:02:42; 08.10.2010 02:09:27; | |
08.10.2010 02:09:36; 08.10.2010 02:09:38; 08.10.2010 02:09:39], | |
[01:53:43; 02:08:59; 01:06:45; 00:00:09; 00:00:02; 00:00:01; 05:50:21]) | |
({Start = 21.10.2010 21:00:00; | |
End = 22.10.2010 08:00:00;}, | |
[22.10.2010 02:05:32; 22.10.2010 02:05:47; 22.10.2010 02:10:30; | |
22.10.2010 02:46:08; 22.10.2010 02:48:30; 22.10.2010 02:58:52; | |
22.10.2010 02:59:45], | |
[05:05:32; 00:00:15; 00:04:43; 00:35:38; 00:02:22; 00:10:22; 00:00:53; 05:00:15]) | |
({Start = 31.10.2010 21:00:00; | |
End = 01.11.2010 08:00:00;}, [01.11.2010 01:51:07; 01.11.2010 02:09:27], | |
[04:51:07; 00:18:20; 05:50:33]) | |
({Start = 01.12.2010 21:00:00; | |
End = 02.12.2010 08:00:00;}, | |
[02.12.2010 00:37:55; 02.12.2010 00:37:57; 02.12.2010 01:17:46], | |
[03:37:55; 00:00:02; 00:39:49; 06:42:14]) | |
({Start = 03.12.2010 21:00:00; | |
End = 04.12.2010 08:00:00;}, [04.12.2010 02:57:44], [05:57:44; 05:02:16]) | |
({Start = 05.12.2010 21:00:00; | |
End = 06.12.2010 08:00:00;}, | |
[05.12.2010 23:37:37; 05.12.2010 23:38:29; 06.12.2010 01:25:36; | |
06.12.2010 01:43:27; 06.12.2010 01:44:17], | |
[02:37:37; 00:00:52; 01:47:07; 00:17:51; 00:00:50; 06:15:43]) | |
({Start = 08.12.2010 21:00:00; | |
End = 09.12.2010 08:00:00;}, [09.12.2010 01:29:33; 09.12.2010 07:53:43], | |
[04:29:33; 06:24:10; 00:06:17]) | |
({Start = 19.12.2010 21:00:00; | |
End = 20.12.2010 08:00:00;}, [19.12.2010 23:41:39; 20.12.2010 01:46:08], | |
[02:41:39; 02:04:29; 06:13:52]) | |
({Start = 22.12.2010 21:00:00; | |
End = 23.12.2010 08:00:00;}, | |
[23.12.2010 01:04:02; 23.12.2010 01:07:10; 23.12.2010 01:07:12; | |
23.12.2010 01:07:13; 23.12.2010 02:30:56; 23.12.2010 02:34:20], | |
[04:04:02; 00:03:08; 00:00:02; 00:00:01; 01:23:43; 00:03:24; 05:25:40]) | |
({Start = 01.01.2011 21:00:00; | |
End = 02.01.2011 08:00:00;}, [02.01.2011 01:19:16], [04:19:16; 06:40:44]) | |
({Start = 10.02.2011 21:00:00; | |
End = 11.02.2011 08:00:00;}, | |
[10.02.2011 22:51:09; 10.02.2011 22:51:09; 10.02.2011 22:51:14; | |
10.02.2011 22:56:32; 11.02.2011 01:03:27; 11.02.2011 01:03:28; | |
11.02.2011 01:03:28; 11.02.2011 01:03:29; 11.02.2011 02:48:54; | |
11.02.2011 02:51:52], | |
[01:51:09; 00:00:00; 00:00:05; 00:05:18; 02:06:55; 00:00:01; 00:00:00; 00:00:01; | |
01:45:25; 00:02:58; 05:08:08]) | |
({Start = 09.04.2011 21:00:00; | |
End = 10.04.2011 08:00:00;}, | |
[09.04.2011 22:00:19; 09.04.2011 22:03:01; 09.04.2011 22:26:48; | |
09.04.2011 22:27:15; 10.04.2011 02:22:17; 10.04.2011 02:45:32], | |
[01:00:19; 00:02:42; 00:23:47; 00:00:27; 03:55:02; 00:23:15; 05:14:28]) | |
({Start = 25.04.2011 21:00:00; | |
End = 26.04.2011 08:00:00;}, | |
[26.04.2011 00:51:13; 26.04.2011 00:55:06; 26.04.2011 07:53:17], | |
[03:51:13; 00:03:53; 06:58:11; 00:06:43]) | |
({Start = 26.04.2011 21:00:00; | |
End = 27.04.2011 08:00:00;}, [27.04.2011 00:37:38; 27.04.2011 07:35:14], | |
[03:37:38; 06:57:36; 00:24:46]) | |
({Start = 04.06.2011 21:00:00; | |
End = 05.06.2011 08:00:00;}, [05.06.2011 01:20:57], [04:20:57; 06:39:03]) | |
({Start = 05.06.2011 21:00:00; | |
End = 06.06.2011 08:00:00;}, | |
[06.06.2011 00:39:39; 06.06.2011 00:40:03; 06.06.2011 00:40:13; | |
06.06.2011 00:40:40; 06.06.2011 00:40:46; 06.06.2011 00:40:50; | |
06.06.2011 00:40:56; 06.06.2011 00:41:20; 06.06.2011 00:41:35; | |
06.06.2011 01:03:54], | |
[03:39:39; 00:00:24; 00:00:10; 00:00:27; 00:00:06; 00:00:04; 00:00:06; 00:00:24; | |
00:00:15; 00:22:19; 06:56:06]) | |
({Start = 07.06.2011 21:00:00; | |
End = 08.06.2011 08:00:00;}, [08.06.2011 01:09:19], [04:09:19; 06:50:41]) | |
({Start = 23.06.2011 21:00:00; | |
End = 24.06.2011 08:00:00;}, | |
[24.06.2011 00:36:32; 24.06.2011 00:37:08; 24.06.2011 07:34:56], | |
[03:36:32; 00:00:36; 06:57:48; 00:25:04]) | |
({Start = 30.06.2011 21:00:00; | |
End = 01.07.2011 08:00:00;}, [01.07.2011 03:31:02], [06:31:02; 04:28:58]) | |
({Start = 07.07.2011 21:00:00; | |
End = 08.07.2011 08:00:00;}, [08.07.2011 01:34:02; 08.07.2011 01:35:36], | |
[04:34:02; 00:01:34; 06:24:24]) | |
({Start = 22.07.2011 21:00:00; | |
End = 23.07.2011 08:00:00;}, | |
[23.07.2011 00:06:42; 23.07.2011 02:30:08; 23.07.2011 03:05:32], | |
[03:06:42; 02:23:26; 00:35:24; 04:54:28]) | |
({Start = 28.07.2011 21:00:00; | |
End = 29.07.2011 08:00:00;}, [29.07.2011 02:00:21], [05:00:21; 05:59:39]) | |
({Start = 14.08.2011 21:00:00; | |
End = 15.08.2011 08:00:00;}, [15.08.2011 00:15:31; 15.08.2011 01:13:26], | |
[03:15:31; 00:57:55; 06:46:34]) | |
({Start = 25.08.2011 21:00:00; | |
End = 26.08.2011 08:00:00;}, [26.08.2011 02:40:26; 26.08.2011 02:41:09], | |
[05:40:26; 00:00:43; 05:18:51]) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.IO | |
type Period = {Start:DateTime; End:DateTime;} | |
let data = File.ReadAllLines("maildatoer.txt") | |
|> List.ofArray | |
|> List.map (fun timeString -> timeString.Trim('"')) | |
|> List.map DateTime.Parse | |
|> List.choose (fun parsedTime -> | |
match parsedTime.Hour with | |
| h when h > 21 -> | |
Some({Start = parsedTime.Date.AddHours(21.0); | |
End = parsedTime.Date.AddDays(1.0).AddHours(8.0)} | |
, parsedTime) | |
| h when h < 8 -> | |
Some({Start = parsedTime.Date.AddDays(-1.0).AddHours(21.0); | |
End = parsedTime.Date.AddHours(8.0)} | |
, parsedTime) | |
| _ -> | |
None) | |
|> Seq.groupBy (fun (period,timeEntries) -> period) | |
|> List.ofSeq | |
|> List.map (fun (period, timeEntries) -> | |
let sortedTimesOfPeriod = | |
timeEntries | |
|> Seq.map(fun (_,t) -> t) | |
|> List.ofSeq | |
|> List.sort | |
let durations = | |
List.map2 (fun iStart iEnd -> iEnd - iStart) | |
([period.Start] @ sortedTimesOfPeriod) | |
(sortedTimesOfPeriod @ [period.End]) | |
(period, sortedTimesOfPeriod, durations)) | |
|> List.filter (fun (_,_,durations) -> | |
not (durations | |
|> List.exists (fun duration -> duration > TimeSpan.FromHours(7.0)))) | |
|> List.sortBy (fun (period,_,_) -> period.Start) | |
File.WriteAllLines("maildatoerfiltered.txt", data |> List.map (fun d -> sprintf "%A" d)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment