Kind of puzzled about timestamps
Bruce Labitt
bruce.labitt at myfairpoint.net
Thu Mar 4 20:49:06 EST 2021
Weird, it is just the 5 hours between UT and EST. The files are
generated on a non-linux embedded machine.
If I create a file on my pc, then the TZ information is present and the
time is set. ls reads it correctly.
This time stuff can get confusing. As you were.
On 3/4/21 7:13 PM, Bruce Labitt wrote:
> 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.
>
>
>
> On Thu, Mar 4, 2021, 7:05 PM Dana Nowell
> <dananowell at cornerstonesoftware.com
> <mailto:dananowell at cornerstonesoftware.com>> wrote:
>
> If I'm reading it correctly, it's a 5 hr difference? Local vs gmt?
>
>
> On Thu, Mar 4, 2021, 6:43 PM Bruce Labitt
> <bruce.labitt at myfairpoint.net
> <mailto:bruce.labitt at myfairpoint.net>> wrote:
>
> This is an odd question. It involves both python and linux.
>
> 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)
>
> $ lsb_release -d Ubuntu 20.04.2 LTS
> $ nautilus --version GNOME nautilus 3.36.3
>
> $ python3 --version Python 3.8.5
>
> $ ls -lght
>
> total 4.7M
> -rw-r--r-- 1 bruce 209K Feb 26 01:49 20210226_022134_PLD.edf
> -rw-r--r-- 1 bruce 65K Feb 26 01:49 20210226_022134_SAD.edf
> -rw-r--r-- 1 bruce 2.4M Feb 26 01:49 20210226_022133_BRP.edf
> -rw-r--r-- 1 bruce 1.1K Feb 26 00:58 20210225_224134_EVE.edf
> -rw-r--r-- 1 bruce 1.9M Feb 25 21:18 20210225_224141_BRP.edf
> -rw-r--r-- 1 bruce 169K Feb 25 21:17 20210225_224142_PLD.edf
> -rw-r--r-- 1 bruce 53K Feb 25 21:17 20210225_224142_SAD.edf
>
> Python3 script
>
> #!/usr/bin/env python3
> import os
> from datetime import datetime
>
> def convert_date(timestamp):
> d = datetime.utcfromtimestamp(timestamp)
> formatted_date = d.strftime('%d %b %Y %H:%M:%S')
> return formatted_date
>
> with os.scandir('feb262021') as entries:
> for entry in entries:
> if entry.is_file():
> info = entry.stat()
> print(f'{entry.name <http://entry.name>}\t Last
> Modified: {convert_date(info.st_mtime) }' ) # last modification
>
> info /(after exit) contains/: 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)
>
> Running the script results in:
>
> 20210226_022133_BRP.edf Last Modified: 26 Feb 2021 06:49:34
> 20210225_224141_BRP.edf Last Modified: 26 Feb 2021 02:18:42
> 20210225_224142_PLD.edf Last Modified: 26 Feb 2021 02:17:44
> 20210225_224142_SAD.edf Last Modified: 26 Feb 2021 02:17:44
> 20210225_224134_EVE.edf Last Modified: 26 Feb 2021 05:58:26
> 20210226_022134_SAD.edf Last Modified: 26 Feb 2021 06:49:36
> 20210226_022134_PLD.edf Last Modified: 26 Feb 2021 06:49:36
>
> Actually, what is returned by my script is at least sensible,
> given that 20210225_224141_BRP.edf 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.
> 20210226_022133_BRP.edf 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 *ls* is reporting.
>
> Do *ls* and python3 use different definitions of "last modified"?
>
> 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
>
> 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?
>
> 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.
>
>
> _______________________________________________
> gnhlug-discuss mailing list
> gnhlug-discuss at mail.gnhlug.org
> <mailto:gnhlug-discuss at mail.gnhlug.org>
> http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/
> <http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/>
>
> _______________________________________________
> gnhlug-discuss mailing list
> gnhlug-discuss at mail.gnhlug.org <mailto:gnhlug-discuss at mail.gnhlug.org>
> http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/
> <http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/>
>
>
> _______________________________________________
> gnhlug-discuss mailing list
> gnhlug-discuss at mail.gnhlug.org
> http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.gnhlug.org/pipermail/gnhlug-discuss/attachments/20210304/352f2475/attachment-0001.html
More information about the gnhlug-discuss
mailing list