Kind of puzzled about timestamps

Jerry Feldman gaf.linux at gmail.com
Thu Mar 4 19:51:54 EST 2021


The time stamps are UTC. The utilities translate them using the standard
time utilities

--
Jerry Feldman <gaf.linux at gmail.com>
Boston Linux and Unix http://www.blu.org
PGP key id: 6F6BB6E7
PGP Key fingerprint: 0EDC 2FF5 53A6 8EED 84D1  3050 5715 B88D 6F6
B B6E7

On Thu, Mar 4, 2021, 7:14 PM Bruce Labitt <bdlabitt at gmail.com> 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> 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>
>> 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}\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
>>> 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/
>>
> _______________________________________________
> 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/7d7672cf/attachment.html 


More information about the gnhlug-discuss mailing list