Skip to contents

An mzQC-formatted date+time in ISO8601 format, as required by the mzQC spec doc.

An mzQC-formatted date+time in ISO8601 format, as required by the mzQC spec doc.

Details

The format is "%Y-%m-%dT%H:%M:%S".

Public fields

datetime

A correctly formatted date time (use as read-only)

Methods


Method new()

Constructor

Usage

Arguments

date

Optional POSIXct value for initialization of field datetime. Defaults to Sys.time()


Method set()

Sets datetime value

Usage

MzQCDateTime$set(date)

Arguments

date

New date-time


Method isValid()

Verifies validity of the object

Usage

MzQCDateTime$isValid(context = "MzQCDateTime")

Arguments

context

Optional string describing location in mzQC structure that is used for more informative warning texts.


Method toJSON()

Creates JSON file from this object.

Usage

MzQCDateTime$toJSON(...)

Arguments

...

Optional parameters for jsonlite:::asJSON()


Method fromData()

Sets data for this object from plain named lists of R objects

Usage

MzQCDateTime$fromData(data, context = "MzQCDateTime")

Arguments

data

A datastructure of R lists/arrays as obtained by 'jsonlite::fromJSON()'

context

Optional string describing location in mzQC structure that is used for more informative warning texts.


Method clone()

The objects of this class are cloneable with this method.

Usage

MzQCDateTime$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

   dt1 = MzQCDateTime$new("1900-01-01")  ## yields "1900-01-01T00:00:00Z"
   dt2 = MzQCDateTime$new(Sys.time())
   ## test faulty input
   ## errors with 'character string is not in a standard unambiguous format'
   try(MzQCDateTime$new('lala'), silent=TRUE)
   ## test roundtrip conversion from/to JSON
   dt2$fromData(jsonlite::fromJSON(jsonlite::toJSON(dt1)))
#> <MzQCDateTime>
#>   Public:
#>     clone: function (deep = FALSE) 
#>     datetime: 1900-01-01T00:00:00Z
#>     fromData: function (data, context = "MzQCDateTime") 
#>     initialize: function (date = as.character(Sys.time())) 
#>     isValid: function (context = "MzQCDateTime") 
#>     self: MzQCDateTime, R6
#>     set: function (date) 
#>     toJSON: function (...)