Skip to content

Commit

Permalink
Add the timezone to the time output
Browse files Browse the repository at this point in the history
Adds the timezone to the time string on ChannelFinder updates

For example,
timezone = False time produces:
2024-05-08 12:55:18.722180
timezone = True (Berlin Time) time produces:
2024-05-08 12:55:18.722180+02:00
  • Loading branch information
jacomago committed May 8, 2024
1 parent 8e5d01d commit 6ea02fc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions server/cf.conf
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,5 @@ procs = cf
# specifying which environment VARIABLEs to pass on to the channel finder
# and defining the corresponding PropertyName
#environment_vars=ENGINEER:Engineer,EPICS_BASE:EpicsVersion,PWD:WorkingDirectory
#Specify the timezone in the time output
timezone = True
2 changes: 2 additions & 0 deletions server/demo.conf
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,5 @@ idkey = 42
# specifying which environment VARIABLEs to pass on to the channel finder
# and defining the corresponding PropertyName
#environment_vars=ENGINEER:Engineer,EPICS_BASE:EpicsVersion,PWD:WorkingDirectory
#Specify the timezone in the time output
timezone = True
6 changes: 4 additions & 2 deletions server/recceiver/cfstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def _commitWithThread(self, TR):
iocName = TR.infos.get('IOCNAME') or TR.src.port
hostName = TR.infos.get('HOSTNAME') or TR.src.host
owner = TR.infos.get('ENGINEER') or TR.infos.get('CF_USERNAME') or self.conf.get('username', 'cfstore')
time = self.currentTime()
time = self.currentTime(timezone=self.conf.get('timezone', None))

"""The unique identifier for a particular IOC"""
iocid = host + ":" + str(port)
Expand Down Expand Up @@ -540,7 +540,9 @@ def __merge_property_lists(newProperties, oldProperties):
return newProperties


def getCurrentTime():
def getCurrentTime(timezone=False):
if timezone:
return str(datetime.datetime.now().astimezone())
return str(datetime.datetime.now())


Expand Down

0 comments on commit 6ea02fc

Please sign in to comment.