Child pages
  • OMK::Common public methods
Skip to end of metadata
Go to start of metadata

Module OMK::Common;

       Usefull common methods.


             Read file that contains hash data, with or without lock, and optionally also



 file (a full path),

               format (optional, 'nmis' or 'json', if not set: guess from file extension

or assume nmis), lock (optional, defaults false),

cache (optional, default false, IFF set return the material from cache -

but this is LIVE and SHARED data! you have to use Clone if your app needs

to change anything in this structure!)


undef on error (sets error_string), (hash reference, filehandle) if lock,

(hash reference) otherwise.



             write hash structure to a file, as json or nmis/perl dump


file (a full path), data (hash ref), both required

handle (optional, open filehandle, if present it's expected to be locked

 and NO locking takes place!

format (optional, 'nmis' or 'json', if not present format is guessed from

file extension)

cache (optional, if set to 1 data is fed to setOmkCache)

             attention: if format is not given, and the file arg doesn't have an extension,

             then the extension .nmis is automatically added!

             returns: (status, error), with status 1 being good.


             Returns unix epoch seconds in utc.



takes anything that time::parsedate understands, plus an optional timezone argument

and returns full seconds (ie. unix epoch seconds in utc)


             if no timezone is given, the configured timezone omkd_display_timezone or local is used.


             attention: parsedate by itself does NOT understand the iso8601 format with timezone Z or

             with negative offset; relative time specs also don't work well with timezones OR dst changes!



             Convert an iso8601/rfc3339 time into (fractional!) unix epoch seconds 

               YYYY-MM-DDTHH:MM:SS.SSS, millis are optional

               also allowed: timezone suffixes Z, +NN, -NN, +NNMM, -NNMM, +NN:MM, -NN:MM


             returns: undef if the input string is invalid

             note: timezone suffixes ARE parsed and taken into account! if no tz suffix is present, use the local timezone


  • No labels