Re: calculate diff between dates

2022-07-14 Thread Michael F. Stemper

On 12/07/2022 07.37, נתי שטרן wrote:

[snip ugly code that I'm not going to try to understand]



I glad for any help


There wasn't any question in your post. However, I'm going to
guess that there was the implied question of "How does one
find the difference between two dates?"


 >>> import datetime
 >>> d1 = datetime.date(2022,1,1)
 >>> d2 = datetime.date(2022,7,12)
 >>> d2-d1
 datetime.timedelta(192)
 >>>


--
Michael F. Stemper
If it isn't running programs and it isn't fusing atoms, it's just bending space.
--
https://mail.python.org/mailman/listinfo/python-list


Re: calculate diff between dates

2022-07-13 Thread Roel Schroeven

Op 12/07/2022 om 14:37 schreef נתי שטרן:

I glad for any help

http://www.catb.org/~esr/faqs/smart-questions.html

--
"Binnen een begrensde ruimte ligt een kritiek punt, waar voorbij de vrijheid
afneemt naarmate het aantal individuen stijgt. Dit gaat evenzeer op voor mensen
in de begrensde ruimte van een planetair ecosysteem, als voor de gasmoleculen
in een hermetisch gesloten vat. Bij mensen is het niet de vraag hoeveel er
maximaal in leven kunnen blijven in het systeem, maar wat voor soort bestaan
mogelijk is voor diegenen die in leven blijven.
  -- Pardot Kynes, eerste planetoloog van Arrakis"
  -- Frank Herbert, Duin

--
https://mail.python.org/mailman/listinfo/python-list


Re: calculate diff between dates

2022-07-12 Thread 2QdxY4RzWzUUiLuE
On 2022-07-12 at 15:37:55 +0300,
נתי שטרן  wrote:

> I glad for any help

http://www.sscce.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


calculate diff between dates

2022-07-12 Thread נתי שטרן
code:
@app.route("/hosts/last_seen")
def hst():
#F1=falconpy
#rr=struct_time()
#rr.tm_hour=23
#F= falconpy.APIHarness(client_id=client_id,client_secret=secret)
#id_list = 'ID1,ID2,ID3'  # Can also pass a list here: ['ID1', 'ID2',
'ID3']
#response = F1.Hosts(client_id=client_id,client_secret=secret)
d=datetime.datetime.fromtimestamp((datetime.datetime.now().utcnow().
timestamp()-86400*1.4)).isoformat()

#F.command()
   # lasts=response.query_devices_by_filter(sort="hostname.asc")
  #  return response.query_devices_by_filter(filter=f"hostname:{myid}*")
#.QueryDevicesByFilter(filter=f"host:{myid}*")
 # )
j=json2html.Json2Html
#f.close()
 #   hostname_result = hosts.query_devices_by_filter(filter=f""
response = dict(a=falconpy.APIHarness(client_id=client_id,client_secret=
secret).command("GetDeviceDetails", ids=list_of_aid))
   # t=response["b"]
   #
t=falconpy.APIHarness(client_id=client_id,client_secret=secret).command("getHostGroups",
ids=response["a"]["body"]["resources"][0]["groups"])

#j=falconpy.APIHarness(client_id=client_id,client_secret=secret).command("query_hosts",filter='8d9285525ada4736bbd9368a2006f0ec')
to=[]
tc=list(range(len(response['a']['body']["resources"])))
for i in response['a']['body']["resources"]:
to.append((datetime.datetime.today())-datetime.datetime().
fromisoformat(str(i["last_seen"])))
return dict(x=to,y=tc)




I glad for any help
-- 
https://mail.python.org/mailman/listinfo/python-list