<commit_before>app.factory('ParseJSONSchedule', [
	'WarningList',
	'DataTypes',
	'UNIXTime',
	function(WarningList, DataTypes, UNIXTime) {
		return {
			parseJSONSchedule: function(options, data, filename) {
				var sessions = options.sessions,
					annotaitons = options.annotations,
					location_map = options.locations,
					submissions = options.submissions,
					addWarning = options.addWarning,
					schedule = options.schedule,
					timezone = options.timezone;

				_.each(data, function(day) {
					var date = day.date,
						stripped_date = date.replace("th", "").replace("st", "").replace("nd", "").replace("rd", "");
					_.each(day.slots, function(slot) {
						var time = slot.time,
							times = time.split("-"),
							start_time = stripped_date + " " + times[0].trim(),
							end_time = stripped_date + " " + times[1].trim();

						date_problem = !Date.parse(stripped_date);
						if(date_problem) {
							warnings.add(filename, "Could not parse date '" + date + "'. Try using the format MMM DD, YYYY (e.g. Apr 29, 2013)");
						} else {
							if(!Date.parse(start_time)) {
								warnings.add(filename, "Could not parse time '" + start_time + "'. Try using the format HH:MM AM/PM (e.g. 1:00 PM)");
							}

							if(!Date.parse(end_time)) {
								warnings.add(filename, "Could not parse end time '" + end_time + "'. Try using the format HH:MM AM/PM (e.g. 1:00 PM)");
							}
						}


						var start_tstamp = UNIXTime.getUnixTime(start_time, timezone),
							end_tstamp = UNIXTime.getUnixTime(end_time, timezone),
							start = start_tstamp.unix(),
							end = end_tstamp.unix(),
							offset = start_tstamp._offset;

						_.each(slot.sessions, function(session_info) {
							var unique_id = session_info.session,
								session = sessions[unique_id],
								loc = location_map[session_info.room];

							session.start = start;
							session.end = end;
							session.offset = offset;
							session.location = session.location || loc;

							schedule.push(session);
						});
					});
				});
			}
		};
	}
]);
/*

var read_json = require('./read_json').read_json,
	data_type = require('../data_types'),
	moment = require('moment-timezone'),
	my_date_offset = (new Date()).getTimezoneOffset() * 60,
	obj_clone = function(obj) {
		var new_obj = {}, key, val;
		for(key in obj) {
			if(obj.hasOwnProperty(key)) {
				val = obj[key];
				new_obj[key] = val;
			}
		}
		return new_obj;<commit_msg>schedule bugfix<commit_after>app.factory('ParseJSONSchedule', [
	'WarningList',
	'DataTypes',
	'UNIXTime',
	function(WarningList, DataTypes, UNIXTime) {
		return {
			parseJSONSchedule: function(options, data, filename) {
				var sessions = options.sessions,
					annotaitons = options.annotations,
					location_map = options.locations,
					submissions = options.submissions,
					addWarning = options.addWarning,
					schedule = options.schedule,
					timezone = options.timezone;

				_.each(data, function(day) {
					var date = day.date,
						stripped_date = date.replace("th", "").replace("st", "").replace("nd", "").replace("rd", "");
					_.each(day.slots, function(slot) {
						var time = slot.time,
							times = time.split("-"),
							start_time = stripped_date + " " + times[0].trim(),
							end_time = stripped_date + " " + times[1].trim();

						date_problem = !Date.parse(stripped_date);
						if(date_problem) {
							warnings.add(filename, "Could not parse date '" + date + "'. Try using the format MMM DD, YYYY (e.g. Apr 29, 2013)");
						} else {
							if(!Date.parse(start_time)) {
								warnings.add(filename, "Could not parse time '" + start_time + "'. Try using the format HH:MM AM/PM (e.g. 1:00 PM)");
							}

							if(!Date.parse(end_time)) {
								warnings.add(filename, "Could not parse end time '" + end_time + "'. Try using the format HH:MM AM/PM (e.g. 1:00 PM)");
							}
						}


						var start_tstamp = UNIXTime.getUnixTime(start_time, timezone),
							end_tstamp = UNIXTime.getUnixTime(end_time, timezone),
							start = start_tstamp.unix(),
							end = end_tstamp.unix(),
							offset = start_tstamp._offset;

						_.each(slot.sessions, function(session_info) {
							var unique_id = session_info.session,
								session = sessions[unique_id],
								loc = location_map[session_info.room];

							if(session) {
								session.start = start;
								session.end = end;
								session.offset = offset;
								session.location = session.location || loc;

								schedule.push(session);
							} else {
								warnings.add(filename, "Could not find session '" + unique_id + "'");
							}
						});
					});
				});
			}
		};
	}
]);
/*

var read_json = require('./read_json').read_json,
	data_type = require('../data_types'),
	moment = require('moment-timezone'),
	my_date_offset = (new Date()).getTimezoneOffset() * 60,
	obj_clone = function(obj) {
		var new_obj = {}, key, val;
		for(key in obj) {
			if(obj.hasOwnProperty(key)) {
				val = obj[key];
				new_obj[key] = val;
			}
		}
		return new_obj;
{'fraction_non_alphanumeric': 0.15170897461523086, 'fraction_numerical': 0.006396162302618429, 'mean_word_length': 2.811119573495811, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '961578', 'n_tokens_mistral': 2212, 'n_tokens_neox': 1656, 'n_words': 334}