<commit_before>--[[
Illarion Server

This program is free software: you can redistribute it and/or modify it under
the terms of the GNU Affero General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
details.

You should have received a copy of the GNU Affero General Public License along
with this program.  If not, see <http://www.gnu.org/licenses/>. 
]]
local common = require("base.common")

module("base.time", package.seeall)

daysPerMonth = {31,28,31,30,31,30,31,31,30,31,30,31}
TIMEZONE=-5

--[[
	Converts a unix timestamp into the RL date
	@param timestamp - unix timestamp
	@return year - the year of the given timestamp
	@return month - the month of the given timestamp
	@return day - the day of the given timestamp
	@return hour - the hour of the given timestamp
	@return minute - the minute of the given timestamp
	@return second - the second of the given timestamp
]]
function getRLDateFromUnixTimestamp(timestamp)
	local year=math.floor(1970+ timestamp /31556926)
	local ds=((1970+timestamp/31556926)-year)*31556926
	local month=math.floor(ds/2629743)+1
	local d=math.floor(ds/86400)+1
	local day=math.floor(((ds/2629743+1)-month)*daysPerMonth[month])+2
	local DST=0;
	
	if(month==3)then 
		if(day>=14)then 
			DST=1 else DST=0
		end
	elseif(month==11)then 
		if(day>=7)then 
			DST=0 else DST=1 
		end 
	end
	local hour=math.floor(math.fmod(timestamp,60*60*24)/3600) + 5 + (TIMEZONE) + (DST)
	local minute= math.floor(math.fmod(timestamp,60*60*24)/60 - 60*(hour-DST))
	local second= math.floor(math.fmod(math.fmod(timestamp,60*60*24),60))
	return year, month, day, hour, minute, second;
end<commit_msg>Adjust base.time to new modules<commit_after>--[[
Illarion Server

This program is free software: you can redistribute it and/or modify it under
the terms of the GNU Affero General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
details.

You should have received a copy of the GNU Affero General Public License along
with this program.  If not, see <http://www.gnu.org/licenses/>. 
]]
local common = require("base.common")

local M = {}

M.daysPerMonth = {31,28,31,30,31,30,31,31,30,31,30,31}
local TIMEZONE=-5

--[[
	Converts a unix timestamp into the RL date
	@param timestamp - unix timestamp
	@return year - the year of the given timestamp
	@return month - the month of the given timestamp
	@return day - the day of the given timestamp
	@return hour - the hour of the given timestamp
	@return minute - the minute of the given timestamp
	@return second - the second of the given timestamp
]]
function M.getRLDateFromUnixTimestamp(timestamp)
	local year=math.floor(1970+ timestamp /31556926)
	local ds=((1970+timestamp/31556926)-year)*31556926
	local month=math.floor(ds/2629743)+1
	local d=math.floor(ds/86400)+1
	local day=math.floor(((ds/2629743+1)-month)*M.daysPerMonth[month])+2
	local DST=0;
	
	if(month==3)then 
		if(day>=14)then 
			DST=1 else DST=0
		end
	elseif(month==11)then 
		if(day>=7)then 
			DST=0 else DST=1 
		end 
	end
	local hour=math.floor(math.fmod(timestamp,60*60*24)/3600) + 5 + (TIMEZONE) + (DST)
	local minute= math.floor(math.fmod(timestamp,60*60*24)/60 - 60*(hour-DST))
	local second= math.floor(math.fmod(math.fmod(timestamp,60*60*24),60))
	return year, month, day, hour, minute, second;
end

return M
{'fraction_non_alphanumeric': 0.10342166195009005, 'fraction_numerical': 0.06225881142269102, 'mean_word_length': 4.642960812772134, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4573273', 'n_tokens_mistral': 1419, 'n_tokens_neox': 1264, 'n_words': 450}