Demo Discussion
Forum Config Examples Contributions Vulnerabilities
  Discussion forum about ELOG  Not logged in ELOG logo
icon5.gif   Date conversion, posted by Martin Neumann on Tue Feb 23 12:12:14 2021 
    icon2.gif   Re: Date conversion, posted by Andreas Luedeke on Tue Feb 23 17:20:39 2021 
       icon2.gif   Re: Date conversion, posted by Martin Neumann on Wed Feb 24 08:44:42 2021 
          icon2.gif   Re: Date conversion, posted by Sebastian Schenk on Tue Mar 2 15:17:56 2021 
    icon2.gif   Re: Date conversion, posted by Stefan Ritt on Wed Mar 10 17:30:23 2021 
Message ID: 69309     Entry time: Tue Feb 23 17:20:39 2021     In reply to: 69308     Reply to this: 69310
Icon: Reply  Author: Andreas Luedeke  Author Email: andreas.luedeke@psi.ch 
Category: Question  OS: Linux  ELOG Version: V3.1.4-80633ba 
Subject: Re: Date conversion 

If you define a field as "datetime" then you'll get the standard ELOG input field for datetime. It will be stored as seconds of the epoch (seconds since 1.1.1970).

You can define a field as a default string input, then it is stored as a string. But you can convert that string by a shell scripts into seconds of the epoch. See "subst" command in the documentation of the elog syntax:

Subst <attribute> = <string>
When submitting logbook entries, attribute values can be substituted by some text. This text can contain arbitrary fixed text and following values:
  • $<attribute>: The entered value of the attribute itself
  • $host: The host name where elogd is running
  • $remote_host: The host name of the host from with the entry was submitted
  • $short_name: The login name (if password file is present)
  • $long_name: The full name from the password file for the current user
  • $user_email: The email address from the password file for the current user
  • $logbook: The name of the current logbook
  • $date: The current date, formatted via "Date format"
  • $utcdate: The current UTC date (GMT) and time, formatted via "Date format"
  • $version: The version of the ELOG server in the form x.y.z
  • $revision: The Subversion reversion of the ELOG server as an integer number
  • $shell(<command>): <command> gets passed to the operating system shell and the result is taken for substitution.

Following example use this feature to add the remote host name to the author:
Subst Author = $author from $remote_host

Following example substitutes an attribute with the contents of a file:
  Subst Info = $shell(cat /tmp/filename)              (Unix)
  Subst Info = $shell(type c:\tmp\filename)           (Windows)

A special option are automatically generated tags, which are automatically incremented for each new message. This is achieved by putting #'s into the substitution string, which is used as a placeholder for the incrementing index. Each "#" stands for one digit, thus the statement
Subst Number = XYZ-#####
results in automatically created attributes "Number" of the form
XYZ-00001
XYZ-00002
XYZ-00003
and so on. In addition to the #'s one may specify format specifiers which are passed to the strftime function. This allows to create tags wich contain the current year, month and so on. Once the date part of the attribute changes, the index restarts from one. The statement
Subst Number = XYZ-%Y-%b-###
results in automatically created attributes "Number" of the form
XYZ-2005-Oct-001
XYZ-2005-Oct-002
XYZ-2005-Oct-003

and
XYZ-2005-Nov-001
XYZ-2005-Nov-002

on the next month.
Martin Neumann wrote:

Hi,

I am trying to figure out how ELOG works and I have a problem.

I have one datetime attribute, where I want the user to be able to enter the time in ISO8601 format (YYYY-MM-DD HH:MM) instead of the buttons.

How do I manage that this input is converted correctly into the internal format?

I tried adding a hidden locked Attribute called IntDate and use "Subst IntDate = $start" but the result is dates in 1970, even though I have set the Time Format to "%F %H:%M"

 

ELOG V3.1.5-fe60aaf