<div dir="auto">Originally Unix used an epoch time system defined as the number of seconds since January 1 1970. This was stored in a signed 32 bit integer that flips in 2035. On 64 bit Linux systems it has been redefined as 64 bits. Unix systems all use UTC. Linux normally uses UTC as the base, but because of dual boot, some systems can use local time. PCs use local time. Unix and Linux have a very rich set of time utilities. <br><br><div data-smartmail="gmail_signature">--<br>Jerry Feldman <<a href="mailto:gaf.linux@gmail.com">gaf.linux@gmail.com</a>><br>Boston Linux and Unix <a href="http://www.blu.org">http://www.blu.org</a><br>PGP key id: 6F6BB6E7<br>PGP Key fingerprint: 0EDC 2FF5 53A6 8EED 84D1 3050 5715 B88D 6F6<br>B B6E7</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 4, 2021, 8:49 PM Bruce Labitt <<a href="mailto:bruce.labitt@myfairpoint.net">bruce.labitt@myfairpoint.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div>Weird, it is just the 5 hours between
UT and EST. The files are generated on a non-linux embedded
machine. <br>
</div>
<div>If I create a file on my pc, then the
TZ information is present and the time is set. ls reads it
correctly.</div>
<p>This time stuff can get confusing. As you were.<br>
</p>
<div>On 3/4/21 7:13 PM, Bruce Labitt wrote:<br>
</div>
<blockquote type="cite">
<div dir="auto">Good point. I'll check that. Logging machine was
set to local time EST. But it does have a wireless link, maybe
it set itself internally to UT. Thanks for the hint.
<div dir="auto"><br>
</div>
<div dir="auto"><br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Thu, Mar 4, 2021, 7:05 PM
Dana Nowell <<a href="mailto:dananowell@cornerstonesoftware.com" target="_blank" rel="noreferrer">dananowell@cornerstonesoftware.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="auto">If I'm reading it correctly, it's a 5 hr
difference? Local vs gmt?
<div dir="auto"><br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Thu, Mar 4, 2021, 6:43
PM Bruce Labitt <<a href="mailto:bruce.labitt@myfairpoint.net" rel="noreferrer noreferrer" target="_blank">bruce.labitt@myfairpoint.net</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<p>This is an odd question. It involves both python and
linux.</p>
<p>Have a bunch of files in a directory that I'd like
like to sort by similar names and in time order. This
isn't particularly difficult in python. What is
puzzling me is the modified timestamp returned by
python doesn't match whats reported by the file
manager nautilus or even ls. (ls and nautilus are
consistent)<br>
</p>
<font size="+1" face="monospace">$ lsb_release -d Ubuntu
20.04.2 LTS</font><font size="+1"><br>
<font face="monospace">$ nautilus --version GNOME
nautilus 3.36.3</font><br>
</font>
<p><font size="+1"><font face="monospace">$ python3
--version Python 3.8.5</font></font></p>
<p><font size="+1"><font face="monospace">$ ls -lght</font></font></p>
<font size="+1"><font face="monospace">total 4.7M<br>
-rw-r--r-- 1 bruce 209K Feb 26 01:49
20210226_022134_PLD.edf<br>
-rw-r--r-- 1 bruce 65K Feb 26 01:49
20210226_022134_SAD.edf<br>
-rw-r--r-- 1 bruce 2.4M Feb 26 01:49
20210226_022133_BRP.edf<br>
-rw-r--r-- 1 bruce 1.1K Feb 26 00:58
20210225_224134_EVE.edf<br>
-rw-r--r-- 1 bruce 1.9M Feb 25 21:18
20210225_224141_BRP.edf<br>
-rw-r--r-- 1 bruce 169K Feb 25 21:17
20210225_224142_PLD.edf<br>
-rw-r--r-- 1 bruce 53K Feb 25 21:17
20210225_224142_SAD.edf<br>
<br>
</font></font>
<p>Python3 script</p>
<p><font size="+1" face="monospace">#!/usr/bin/env
python3<br>
import os<br>
from datetime import datetime<br>
<br>
def convert_date(timestamp):<br>
d = datetime.utcfromtimestamp(timestamp)<br>
formatted_date = d.strftime('%d %b %Y %H:%M:%S')<br>
return formatted_date<br>
<br>
with os.scandir('feb262021') as entries:<br>
for entry in entries:<br>
if entry.is_file():<br>
info = entry.stat()<br>
print(f'{<a href="http://entry.name" rel="noreferrer noreferrer noreferrer" target="_blank">entry.name</a>}\t Last
Modified: {convert_date(info.st_mtime) }' ) # last
modification</font><br>
</p>
<p>info <i>(after exit) contains</i>: <font size="+1" face="monospace">os.stat_result(st_mode=33188,
st_ino=34477637, st_dev=66306, st_nlink=1,
st_uid=1000, st_gid=1000, st_size=213416,
st_atime=1614379184, st_mtime=1614322176,
st_ctime=1614379184)</font></p>
<p><font size="+1">Running the script results in: </font><br>
</p>
<p><font face="monospace">20210226_022133_BRP.edf
Last Modified: 26 Feb 2021 06:49:34<br>
20210225_224141_BRP.edf Last Modified: 26 Feb
2021 02:18:42<br>
20210225_224142_PLD.edf Last Modified: 26 Feb
2021 02:17:44<br>
20210225_224142_SAD.edf Last Modified: 26 Feb
2021 02:17:44<br>
20210225_224134_EVE.edf Last Modified: 26 Feb
2021 05:58:26<br>
20210226_022134_SAD.edf Last Modified: 26 Feb
2021 06:49:36<br>
20210226_022134_PLD.edf Last Modified: 26 Feb
2021 06:49:36<br>
</font></p>
<p>Actually, what is returned by my script is at least
sensible, given that <font face="monospace">20210225_224141_BRP.edf</font>
started on Feb 25th and ended recording at 2:17am on
Feb 26th. I know this because I can see the data on a
separate program. <font face="monospace">20210226_022133_BRP.edf
</font>started on Feb 26th at around 2:21am and
terminated at 6:49am. BRP files are written to
continuously at a 25 Hz rate all evening. What makes
no sense whatsoever is what <b>ls</b> is reporting.</p>
<p>Do <b>ls</b> and python3 use different definitions
of "last modified"?</p>
<p>Guess I can keep going, but I really was surprised at
the difference between methods. Default for ls is
"last modified", at least as reported by man. ls's
last modified just isn't correct, at least on Ubuntu
20.04.2</p>
<p>Is this a quirk? Am I doing something wrong? Some
kind of voodoo definition of "last modified"? What
does Linux say "last modified" really means?</p>
<p>FWIW, I am coming up to speed on processing these edf
files to help out on an open source project. Been
working on some data analysis tools. As an aside,
biological data is very messy. It's been a treat to
work on this as it's forced me to dust off the mental
cobwebs and work on a problem that can help a lot of
people.<br>
</p>
<p><br>
</p>
</div>
_______________________________________________<br>
gnhlug-discuss mailing list<br>
<a href="mailto:gnhlug-discuss@mail.gnhlug.org" rel="noreferrer noreferrer noreferrer" target="_blank">gnhlug-discuss@mail.gnhlug.org</a><br>
<a href="http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/" rel="noreferrer noreferrer noreferrer noreferrer" target="_blank">http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/</a><br>
</blockquote>
</div>
_______________________________________________<br>
gnhlug-discuss mailing list<br>
<a href="mailto:gnhlug-discuss@mail.gnhlug.org" rel="noreferrer noreferrer" target="_blank">gnhlug-discuss@mail.gnhlug.org</a><br>
<a href="http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/" rel="noreferrer noreferrer noreferrer" target="_blank">http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/</a><br>
</blockquote>
</div>
<br>
<fieldset></fieldset>
<pre>_______________________________________________
gnhlug-discuss mailing list
<a href="mailto:gnhlug-discuss@mail.gnhlug.org" target="_blank" rel="noreferrer">gnhlug-discuss@mail.gnhlug.org</a>
<a href="http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/" target="_blank" rel="noreferrer">http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/</a>
</pre>
</blockquote>
<p><br>
</p>
</div>
_______________________________________________<br>
gnhlug-discuss mailing list<br>
<a href="mailto:gnhlug-discuss@mail.gnhlug.org" target="_blank" rel="noreferrer">gnhlug-discuss@mail.gnhlug.org</a><br>
<a href="http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/" rel="noreferrer noreferrer" target="_blank">http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/</a><br>
</blockquote></div>