Time interval counting
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Time interval counting

Started by satya, 03 January, 2009, 15:48:59

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

satya

thanks buddy can work will try that right now,

but i have one more thing for u to help me out :D

how can i find the date 5 days before today, i know this sounds funny bt here is wat i wanna do

i wanna keep logs of all last 4 days share by the user, so on every 5th day, the 5 days earlier share shud be deleted.

so i wud get the date of today with os.date("%D") bt how do i find the date 5 days prior from today.

thanks satya

Eyes says everything,
Its on you how u read em...

bastya_elvtars

This is another common problem you are facing. Let's see the code from plop:
-- The following 2 functions are
-- Copyright (c) 2005, plop
-- All rights reserved.
JulianDate = function(tTime)
  tTime = tTime or os.date("*t")
  return os.time({year = tTime.year, month = tTime.month, day = tTime.day, 
    hour = tTime.hour, min = tTime.min, sec = tTime.sec}
  )
end

JulianDiff = function(iThen, iNow)
  return os.difftime( (iNow or JulianDate()) , iThen)
end
-- End of plop's code


Explanation is here.
Everything could have been anything else and it would have just as much meaning.

satya

MUTOR with ur xplanation i understood lil bit, bt again i m not gettin wat to do and how. it will be better if u can xplain me with an example pls.

i think for u to explain in a better way i will show u wat i m tryin to do.

sHare={}
LogShare = function(user,data)
	nIK=user.sNick:lower()
		if sHare[os.date("%D")] then
			if sHare[os.date("%D")][nIK] then
				table.insert (sHare[os.date("%D")][nIK],data)
				SaveRecords()
			else
				sHare[os.date("%D")][nIK]={}
				table.insert (sHare[os.date("%D")][nIK],data)
				SaveRecords()
			end
		else
			sHare[os.date("%D")]={}
			sHare[os.date("%D")][nIK]={}
			table.insert (sHare[os.date("%D")][nIK],data)
			SaveRecords()
		end
	return
end


And heres how to table looks like:

sHare = {
	["01/03/09"] = {
		["pharoh"] = {
			[1] = "yes man",
		},
		["allan"] = {
			[1] = "bedtime stories",
			[2] = "red line",
		},
		["cody"] = {
			[1] = "LOST Se 4",
		},
	},
}



So here as u see dat i m storing the data in the table according to date as indices as said by mutor. Now the reason for this is after 5 days i want the records of the date 5 days prior to today can be easily deleted. which i want to do wen the script starts. For which i want to get a Date wich will be 5 days prior to todays date.

i don know bt i think i m sounding stupid, bt it will be great if u can xplain with a function wich takes arg as date and returns date wich is 5 days prior to arg date.

and in ur post u said

QuoteThis would mean you need to parse that date before you make comparisons.
wat did u meant with dat can u xplain me pls.

it will be really great if u guys can xplain with examples pls

thanks satya

Eyes says everything,
Its on you how u read em...

satya

Hey wats happenin? Where are the mods is there anyone to help pls. :(

Eyes says everything,
Its on you how u read em...

SMF spam blocked by CleanTalk