<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/1181" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2002-03-05T07:10:00-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/1181</id>

		<entry>
		<author><name><![CDATA[stdragon]]></name></author>
		<updated>2002-03-05T07:10:00-04:00</updated>

		<published>2002-03-05T07:10:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=5063#p5063</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=5063#p5063"/>
		<title type="html"><![CDATA[Date [censored].]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=5063#p5063"><![CDATA[
First of all, have you considered using a regular expression instead of all those splits?<br><br>set x [regexp {^([0-9]+)/([0-9]+)/([0-9]+)} $line total day month year]<br><br>Then if x is 0, it didn't match; otherwise, it did, and the parts are already in $day, $month, and $year. $total is the entire thing that matches (i.e. 03/04/90).<br><br>Then, you can use:<br>set day [string trimleft $day 0]<br>etc<br><br>to get rid of leading 0's (this may be screwing up your math, since Tcl will treat the numbers as octal instead of decimal).<br><br>Also... are you aware of the "clock scan" command? You can give it a date, and it will return a number (seconds from jan 1 1970 to that date).<br><br>% clock scan "03/02/90"<br>636354000<br><br>% clock scan "03/03/90"<br>636440400<br><br>The difference in each day is 86400 seconds. So to check if it's 5 days or whatever, see if they're within 5*86400 seconds of each other.<br><br>Oh, btw, the "clock scan" date format is "mm/dd/yy(yy)".<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8">stdragon</a> — Tue Mar 05, 2002 7:10 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2002-03-04T19:30:00-04:00</updated>

		<published>2002-03-04T19:30:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=5051#p5051</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=5051#p5051"/>
		<title type="html"><![CDATA[Date [censored].]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=5051#p5051"><![CDATA[
Hi all.<br><br>I'm working on a tcl script which should clear all lines older as 5 days from a file.<br>The lines ar timestamped in format: DD/MM/YY hh:mm:ss &lt;line&gt;<br><br>i got this now:<br><div class="codebox"><p>Code: </p><pre><code>  foreach line [split $file "n"] {    if { $line != "n" || $line != " n" || $line != " " } {      set fdate [lindex [split $line " "] 0]      set fday [lindex [split $fdate "/"] 0]      set fmonth [lindex [split $fdate "/"] 1]      set fyear [lindex [split $fdate "/"] 2]      set day3 [checkdate $fday $fmonth $fyear $day $month $year]      putserv "PRIVMSG $chn :$day3 test"      if { $day3 == 1 } { putserv "PRIVMSG $chn : 1" }      if { $day3 != 1 } { puts $file1 $line }    }  }</code></pre></div>the function checkdate checks if linedate ($fday, $fmonth and $fyear, splitted earlier (checked them, they work correctly)) is 5 ore more days older as the current date. If so, it returns 1, if not, it returns 0.<br>It works with if's and switches (all with " before and after the values, the var's are strings).<br>This won't work (correctly).<br>I also created a proc toint, this converts a string to an int (it's a switch that returns 01 if string is "01", 02 if string is "02" and so on), and checked with simple if's (if { [toint $fday] &lt; [expr [toint $day] +5] } { ...} and sort of xtra checks fore month and year), but it won't work.<br><br>Can someone help me plz?? <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":smile:" title="Smile"><br><br>I know it's kinda hard, but i dunno why it won't work.<br><br>Greejtz, Zygo.<p>Statistics: Posted by Guest — Mon Mar 04, 2002 7:30 pm</p><hr />
]]></content>
	</entry>
	</feed>
