DATETIME

NAME

datetime - Manages date.

SYNOPSIS

datetime(lg:"fr|en",locale:"…",extended:true|false,date:"yyyy-mm-dd hh:mm:ss",op="op…",format:"…", table:string)

DESCRIPTION

This function is used to read a date, perform some operations and output it in a specific format.

The input date supports four formats: - yyyy-mm-dd hh:mm:ss - yyyy-mm-dd - Unix in secs since 1970 and Thu, 19 Apr 2018 11:00:49 +0000.

The operation is a sign, followed by a number then by a single character which can be: - s : second - m : minut - h : hour - d : day - w : week - b : month - y : year

locale : for the locale

lg : for the language. Note that when using this parameter, better to specify which language table should be using:

table: is used to specify the table where the language are defined. 

 

The format supports the usual strftime format, which can be:

Note: In the followings examples, the _ between the { should be removed to make it work.

res={_{datetime(date:"2013-01")}}. res=2013-01-01 00:00:00.
res={_{datetime(date:"2013-01-01")}}. res=2013-01-01 00:00:00.
res={_{datetime(date:"2013-01-01 10")}}. res=2013-01-01 10:00:00.
res={_{datetime(date:"2013-01-01 10:10")}}. res=2013-01-01 10:10:00.
res={_{datetime(date:"2013-01-01 10:10:10")}}. res=2013-01-01 10:10:10.

res={_{ a=datetime(lg:"fr",locale:'fr_CA.utf8',date:"2012-04-01 13:12:44",extended:true,format:"%Sednove1"); a; }}. return res=1er avril.
res={_{
        a=datetime(date:"2012-04-04",extended:true,format:"%Sednove1 %B %Sednove1"
        a;
}}. return res=April 4th April April 4th.),{}
res={_{
        a=datetime(date:"2012-04-04",format:"%s"
        a;
        datetime(date:86400
        datetime(date:a
}}. return res=13335120001970-01-01 19:00:002012-04-04 00:00:00.),{}
res={_{ datetime(date:"1714-04-30",op:"+2d" }}. return res=1714-05-02 00:00:00.),{});
res={_{ datetime(date:"2014-04-30",op:"-13b,+2d" }}. return res=2013-04-01 00:00:00.),{});
res={_{ datetime(date:"2014-04-30",op:"-13b" }}. return res=2013-03-30 00:00:00.),{});
res={_{ datetime(date:"2013-01-31",op:"+13b,+1d" }}. return res=2014-03-01 00:00:00.),{});
res={_{ datetime(date:"2013-01-31",op:"+13b" }}. return res=2014-02-28 00:00:00.),{});
res={_{ datetime(date:"2013-01-01",op:"+365d" }}. return res=2014-01-01 00:00:00.),{});
res={_{ datetime(date:"2013-01-01",op:"+364d" }}. return res=2013-12-31 00:00:00.),{});
res={_{ datetime(date:"2013-04-07 11:34:55" }}. return res=2013-04-07 11:34:55.),{});
res={_{ datetime(date:"2013-04-07" }}. return res=2013-04-07 00:00:00.),{});
res={_{ datetime(date:"1955-04-07" }}. return res=1955-04-07 00:00:00.),{});
res={_{ datetime(date:"1655-04-07" }}. return res=1655-04-07 00:00:00.),{});
res={_{ datetime(date:"2033-04-07" }}. return res=2033-04-07 00:00:00.),{});
res={_{ datetime(date:"2037-04-07" }}. return res=2037-04-07 00:00:00.),{});
res={_{ datetime(date:"2038-04-07" }}. return res=2038-04-07 00:00:00.),{});
res={_{ datetime(date:"2013-06-22 00:34:01",op:"-5s"}}. return res=2013-06-22 00:33:56.),{});
res={_{ datetime(date:"2013-06-22 05:01:59",op:"+5s"}}. return res=2013-06-22 05:02:04.),{});
res={_{ datetime(date:"2013-06-22 05:01:59",op:"+235s"}}. return res=2013-06-22 05:05:54.),{});
res={_{ datetime(date:"2013-06-22 05:01:59",op:"+235s,+2s"}}. return res=2013-06-22 05:05:56.),{});
res={_{ datetime(date:"2013-06-22 05:01:59",op:"+235s,-2s"}}. return res=2013-06-22 05:05:52.),{});
res={_{ datetime(date:"2013-06-22 05:59:59",op:"+5s"}}. return res=2013-06-22 06:00:04.),{});
res={_{ datetime(date:"2013-06-22 12:34:35",op:"+1h"}}. return res=2013-06-22 13:34:35.),{});
res={_{ datetime(date:"2013-06-22 23:34:35",op:"+1h"}}. return res=2013-06-23 00:34:35.),{});
res={_{ datetime(date:"2013-06-30 23:34:35",op:"+1h"}}. return res=2013-07-01 00:34:35.),{});
res={_{ datetime(date:"2013-06-30 23:34:35",op:"+1b"}}. return res=2013-07-30 23:34:35.),{});
res={_{ datetime(date:"2013-01-31 23:34:35",op:"+1b"}}. return res=2013-02-28 23:34:35.),{});
res={_{ datetime(date:"2013-01-31 23:34:35",op:"+1y"}}. return res=2014-01-31 23:34:35.),{});
res={_{ datetime(date:"2013-01-31 23:34:35",op:"+1s"}}. return res=2013-01-31 23:34:36.),{});
res={_{ datetime(date:"2013-01-31 23:34:35",op:"+1m"}}. return res=2013-01-31 23:35:35.),{});
res={_{ datetime(date:"2013-01-31 23:34:35",op:"+1h"}}. return res=2013-02-01 00:34:35.),{});
res={_{ datetime(date:"2013-01-31 23:34:35",op:"-1h"}}. return res=2013-01-31 22:34:35.),{});
res={_{ datetime(date:"2013-05-05", locale:"fr_CA.utf8",format:"%B" }}. return res=mai.),{});
res={_{ datetime(date:"2013-12-05", locale:"fr_CA.utf8",format:"%B" }}. return res=décembre.),{});
res={_{a=date("2011-02-03 12:32:56",format:"%b", locale:"fr_CA.UTF-8" a.format}}. return res=fév.
res={_{a=date("2011-02-03 12:32:56" a.iso}}. return res=2011-02-03.
datetime(date:"2018-02-28", extended:true, lg:"fr", format:"%B", table:"sed_site_lg");

Output of all format

       - %a     The abbreviated weekday name according to the current locale.
Sun

       - %A     The full weekday name according to the current locale.
Sunday

       - %b     The abbreviated month name according to the current locale.
Sep

       - %B     The full month name according to the current locale.
September

       - %c     The preferred date  and  time  representation  for  the  current locale.
Sun Sep 22 09:06:42 2013

       - %C     The century number (year/100) as a 2-digit integer. (SU)
20

       - %d     The day of the month as a decimal number (range 01 to 31).
22

       - %D     Equivalent  to %m/%d/%y. (Yecch — for Americans only.  Americans should note that in other countries %d/%m/%y is  rather  common.
                This  means that in international context this format is ambiguous and should not be used.) (SU)
09/22/13

       - %e     Like %d, the day of the month as a decimal number, but a leading zero is replaced by a space. (SU)
22

       - %E     Modifier: use alternative format, see below. (SU)
%E

       - %F     Equivalent to %Y-%m-%d (the ISO 8601 date format). (C99)
2013-09-22

       - %G     The ISO 8601 year with century as a decimal number.  The 4-digit year corresponding to the ISO week number (see  %V).   This  has
                the  same  format  and  value as %y, except that if the ISO week number belongs to the previous or next year, that year  is  used
                instead. (TZ)
2013

       - %g     Like %G, but without century, i.e., with a 2-digit year (00-99).
               (TZ)
13

       - %h     Equivalent to %b. (SU)
Sep

       - %H     The hour as a decimal number using a 24-hour clock (range 00  to 23).
09

       - %I     The  hour as a decimal number using a 12-hour clock (range 01 to 12).
09

       - %j     The day of the year as a decimal number (range 001 to 366).
265

       - %k     The hour (24-hour clock) as a decimal number (range  0  to  23 single digits are preceded by a blank. (See also %H.) (TZ)
 9

       - %l    The  hour  (12-hour  clock) as a decimal number (range 1 to 12 single digits are preceded by a blank. (See also %I.) (TZ)
 9

       - %m     The month as a decimal number (range 01 to 12).
09

       - %M     The minute as a decimal number (range 00 to 59).
06

       - %n     A newline character. (SU)



       - %O     Modifier: use alternative format, see below. (SU)
%O

       - %p     Either ‘AM’ or ‘PM’ according to the given time  value,  or  the
                corresponding  strings  for the current locale.  Noon is treated as ‘pm’ and midnight 
                as ‘am’.
AM

       - %P     Like %p but in lowercase: ‘am’ or ‘pm’ or a corresponding string
                for the current locale. (GNU)
am

       - %r     The  time in a.m. or p.m. notation.  In the POSIX locale this is equivalent to ‘%I:%M:%S %p’. (SU)
09:06:42 AM

       - %R     The time in 24-hour notation (%H:%M). (SU) For a version including the seconds, see %T below.
09:06

       - %s     The  number  of  seconds since the Epoch, i.e., since 1970-01-01 00:00:00 UTC. (TZ)
1379855202

       - %S     The second as a decimal number (range 00 to 60).  (The range  is up to 60 to allow for occasional leap seconds.)
42

       - %t     A tab character. (SU)


       - %T     The time in 24-hour notation (%H:%M:%S). (SU)
09:06:42

       - %u     The  day of the week as a decimal, range 1 to 7, Monday being 1.
                See also %w. (SU)
7

       - %U     The week number of the current year as a decimal  number,  range 00  to  53,  starting  with the first Sunday as the first day of
                week 01. See also %V and %W.
38

       - %V     The ISO 8601:1988 week number of the current year as  a  decimal number,  range 01 to 53, where week 1 is the first week that has
                at least 4 days in the current year,  and  with  Monday  as  the first day of the week. See also %U and %W. (SU)
38

       - %w     The  day of the week as a decimal, range 0 to 6, Sunday being 0.
                See also %u.
0

       - %W     The week number of the current year as a decimal  number,  range 00 to 53, starting  with the first Monday as the first day of
                week 01.
37

       - %x     The preferred date representation for the current locale without the time.
09/22/13

       - %X     The preferred time representation for the current locale without the date.
09:06:42

       - %y     The year as a decimal number without a century (range 00 to 99).
13

       - %Y     The year as a decimal number including the century.
2013

       - %z     The  time-zone  as  hour  offset  from  GMT.   Required  to emit
                RFC 822-conformant dates (using "%a, %d  %b  %Y  %H:%M:%S  %z").
               (GNU)
-0400

       - %Z     The time zone or name or abbreviation.
EDT

       - %+     The  date  and  time  in  date(1) format. (TZ) (Not supported in glibc2.)
%+

                - Sednove1
September 22nd

                - Sednove2
Sun, 23 Sep 2013 00:51:16 GMT
                - Sednove1
22nd

 

 

SEE ALSO

AUTHOR

Written by Pierre Laplante and Caroline Laplante, <laplante@sednove.com>

MODIFICATIONS

1.0 2014-09-09 21:24:14 laplante@sednove.com

1.1 2018-04-21 laplante@sednove.com Add support for parsing date in format Thu, 19 Apr 2018 11:00:49 +0000 from version 5.104