1
2# This R package is free software; you can redistribute it and/or
3# modify it under the terms of the GNU Library General Public
4# License as published by the Free Software Foundation; either
5# version 2 of the License, or (at your option) any later version.
6#
7# This R package is distributed in the hope that it will be useful,
8# but WITHOUT ANY WARRANTY; without even the implied warranty of
9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10# GNU Library General Public License for more details.
11#
12# You should have received a copy of the GNU Library General
13# Public License along with this R package; if not, write to the
14# Free Foundation, Inc., 59 Temple Place, Suite 330, Boston,
15# MA  02111-1307  USA
16
17
18################################################################################
19# FUNCTION:                 DESCRIPTION:
20#  format.timeDate           Formats 'timeDate' as ISO conform string
21################################################################################
22
23# ---------------------------------------------------------------------------- #
24# Roxygen Tags
25#' @export
26# ---------------------------------------------------------------------------- #
27format.timeDate <- function(x, format = "", tz = "", usetz = FALSE, ...)
28{
29    # A function implemented by Diethelm Wuertz and Yohan Chalabi
30
31    # Description:
32    #   Formats 'timeDate' as ISO conform string
33
34    # FUNCTION:
35
36    if (!inherits(x, "timeDate"))
37        stop("wrong class")
38    if (tz != "")
39        finCenter(x) <- tz
40
41    FinCenter <- finCenter(x)
42
43    num <- .formatFinCenterNum(as.numeric(getDataPart(x)),
44                               FinCenter, type = "gmt2any")
45    ans <- format(as.POSIXct(num, origin = "1970-01-01", tz = "GMT"),
46                  tz = "GMT", format = format)
47    names(ans) <- names(getDataPart(x))
48
49    # Should add tz from table in formatFinCenter
50    if (usetz)
51        ans <- paste(ans, finCenter(x))
52
53    # Return Value:
54    ans
55}
56
57################################################################################
58