FormatTime

From K-3D

Jump to: navigation, search

Description

Image:FormatTime.png Converts a scalar to a string using strftime()-style formatting
Plugin Status:Stable
Categories:All Plugins, Stable Plugins, String Plugins

Metadata

Name Value

Properties

Label Description Type Script Name
Input Timestamp value, or 0 to use current system time k3d::double_t input
Format strftime() format string k3d::string_t format
Output string strftime() output string (read only) k3d::string_t output


Notes

FormatTime is intended for use with TimeSource and RealtimeSource - note that date-related format strings make little sense with the output of TimeSource, since it is typically zero-based.

Valid formatting tokens are those provided by the Boost.DateTime library. These are mostly compatible with strftime() tokens, with some exceptions and additions. See Format Flags for a definitive list of valid tokens.

Format Specifier Description
Example
%a
Abbreviated weekday name
"Mon" => Monday
%A
Long weekday name
"Monday"
%b
Abbreviated month name
"Feb" => February
%B
Full month name
"February"
%c  
The preferred date and time representation for the current locale.
%C  
The century number (year/100) as a 2-digit integer.
%d
Day of the month as decimal 01 to 31
%D  
Equivalent to %m/%d/%y
%e
Like %d, the day of the month as a decimal number, but a leading zero is replaced by a space
%G  
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.
%g  
Like %G, but without century.
%h  
Equivalent to %b
%j
Day of year as decimal from 001 to 366 for leap years, 001 - 365 for non-leap years.
"060" => Feb-29
%m
Month name as a decimal 01 to 12
"01" => January
%u  
The day of the week as a decimal, range 1 to 7, Monday being 1.
%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. In 2005, Jan 1st falls on a Saturday, so therefore it falls within week 00 of 2005 (week 00 spans 2004-Dec-26 to 2005-Jan-01. This also happens to be week 53 of 2004).
%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.
%w
Weekday as decimal number 0 to 6
"0" => Sunday
%W
Week number 00 to 53 where Monday is first day of week 1
%x
Implementation defined date format from the locale.
%y
Two digit year
"05" => 2005
%Y
Four digit year
"2005"
%Y-%b-%d
Default date format
"2005-Apr-01"
%Y%m%d
ISO format
"20050401"
%Y-%m-%d
ISO extended format
"2005-04-01"
%- * 
Placeholder for the sign of a duration. Only displays when the duration is negative.
"-13:15:16"
%+ * 
Placeholder for the sign of a duration. Always displays for both positive and negative.
"+13:15:16"
%f
Fractional seconds are always used, even when their value is zero
"13:15:16.000000"
%F *
Fractional seconds are used only when their value is not zero.
"13:15:16"
  "05:04:03.001234"
            
%O
The number of hours in a time duration as a decimal number (range 0 to max. representable duration); single digits are preceded by a zero.
%I  
The hour as a decimal number using a 12-hour clock
%k  
The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank.
%l  
The hour (12-hour clock) as a decimal number (range 1 to 12); single digits are preceded by a blank.
%p  
Either `AM' or `PM' according to the given time value, or the corresponding strings for the current locale.
%P  
Like %p but in lowercase: `am' or `pm' or a corresponding string for the current locale.
%r  
The time in a.m. or p.m. notation. In the POSIX locale this is equivalent to `%I:%M:%S %p'
%R  
The time in 24-hour notation (%H:%M)
%s *
Seconds with fractional seconds.
"59.000000"
%S
Seconds only
"59"
%T  
The time in 24-hour notation (%H:%M:%S)
%q
ISO time zone (output only). This flag is ignored when using the time_facet with a ptime.
"-0700" // Mountain Standard Time
%Q
ISO extended time zone (output only). This flag is ignored when using the time_facet with a ptime.
"-05:00" // Eastern Standard Time
%z * 
Abbreviated time zone (output only). This flag is ignored when using the time_facet with a ptime.
"MST" // Mountain Standard Time
%Z * 
Full time zone name (output only). This flag is ignored when using the time_facet with a ptime.
"EDT" // Eastern Daylight Time
%ZP *
Posix time zone string (available to both input and output). This flag is ignored when using the time_facet with a ptime. For complete details on posix time zone strings, see posix_time_zone class.
"EST-05EDT+01,M4.1.0/02:00,M10.5.0/02:00"
%x %X
Implementation defined date/time format from the locale.
%Y%m%dT%H%M%S%F%q
ISO format
"20051015T131211-0700"
  // Oct 15, 2005 13:12:11 MST
            
%Y-%m-%d %H:%M:%S%F%Q
Extended ISO format
"2005-10-15 13:12:11-07:00"
%Y-%b-%d %H:%M:%S%F %z
Default format used when outputting ptime and local_date_time.
"2005-Oct-15 13:12:11 MST"
%Y-%b-%d %H:%M:%S%F %ZP
Default format used when inputting ptime and local_date_time.
"2005-Oct-15 13:12:11 MST-07"
%-%H:%M:%S%F  
Default time_duration format for output. Sign will only be displayed for negative durations.
"-13:14:15.003400"
%H:%M:%S%F
Default time_duration format for input.
"13:14:15.003400"

* Signifies flags that differ from or are unavailable via strftime().

Views
Personal tools
Navigation
Toolbox