<commit_before>var fs = require('fs');
var express = require('express');
var app = express();

app.set('views', './views');
app.set('view engine', 'jade');

app.get('/', function (req, res) {
	res.render('index', {
		'timeSinceLastDate': 0
	});
});

app.get('/days', function (req, res) {
	var latestDate = new Date();

	try {
		var log = fs.readFileSync('static/log.txt','utf8');
    	var lines = log.trim().split('\n');
    	var lastLine = lines.slice(-1)[0];
	    if (lines.length > 0) {
	    	latestDate = new Date(lastLine);
	    }
	} catch (error) {
		console.log('no log file found');
	}

	latestDate.setHours(0,0,0);
	var now = new Date();
	now.setHours(0,0,0);
	
    var	timeSinceLastDate = Math.round((now.getTime() - latestDate.getTime()) / (1000*60*60*24));

	res.send({
		days: timeSinceLastDate,
		date: latestDate
	});
});

app.get('/update', function (req, res) {
	var date = new Date().toISOString()
	fs.appendFile('static/log.txt', date + '\n', function (err) {
		if (err) {
			res.status(500).send({error: 'Unable to write to log'});
		} else {
			res.send({
				days: 0,
				date: date
			});
		}
	});

});
<commit_msg>change date calculation<commit_after>var fs = require('fs');
var express = require('express');
var app = express();

app.set('views', './views');
app.set('view engine', 'jade');

app.get('/', function (req, res) {
	res.render('index', {
		'timeSinceLastDate': 0
	});
});

app.get('/days', function (req, res) {
	var latestDate = new Date();

	try {
		var log = fs.readFileSync('static/log.txt','utf8');
    	var lines = log.trim().split('\n');
    	var lastLine = lines.slice(-1)[0];
	    if (lines.length > 0) {
	    	latestDate = new Date(lastLine);
	    }
	} catch (error) {
		console.log('no log file found');
	}

	latestDate.setHours(23,59,0);
	var now = new Date();

    var	timeSinceLastDate = Math.ceil((now.getTime() - latestDate.getTime()) / (1000*60*60*24));

	res.send({
		days: timeSinceLastDate,
		date: latestDate
	});
});

app.get('/update', function (req, res) {
	var date = new Date().toISOString()
	fs.appendFile('static/log.txt', date + '\n', function (err) {
		if (err) {
			res.status(500).send({error: 'Unable to write to log'});
		} else {
			res.send({
				days: 0,
				date: date
			});
		}
	});

});

{'fraction_non_alphanumeric': 0.2118270079435128, 'fraction_numerical': 0.021624007060900265, 'mean_word_length': 3.4538310412573674, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4058476', 'n_tokens_mistral': 916, 'n_tokens_neox': 838, 'n_words': 189}