Difference between pages "Is trendy" and "Format date time"

From Kolmafia
(Difference between pages)
Jump to navigation Jump to search
imported>Eliteofdelete
 
imported>Bale
(r10078 & r10081)
 
Line 1: Line 1:
 
{{
 
{{
#vardefine:name|is_trendy}}{{
+
#vardefine:name|format_date_time}}{{
#vardefine:return_type|boolean}}{{
+
#vardefine:return_type|string}}{{
  
 
FunctionPage|
 
FunctionPage|
Line 11: Line 11:
 
return_type={{#var:return_type}}|
 
return_type={{#var:return_type}}|
 
return_also={{#var:return_also}}|
 
return_also={{#var:return_also}}|
parameter1={{Param|item|thing}}|
+
parameter1={{Param|string|inFormat}}|
 +
parameter2={{Param|string|dtg}}|
 +
parameter3={{Param|string|outFormat}}|
 +
p1desc={{pspan|inFormat}} is how the input string is formatted.|
 +
p2desc={{pspan|dtg}} is the time to reformat.|
 +
p3desc={{pspan|outFormat}} is how the output string should be formatted.|
 
}}|
 
}}|
  
function2={{Function|
+
function_description=Full information on [http://download.oracle.com/javase/1.3/docs/api/java/text/SimpleDateFormat.html SimpleDateFormat] here.|
name={{#var:name}}|
 
aggregate={{#var:aggregate}}|
 
return_type={{#var:return_type}}|
 
return_also={{#var:return_also}}|
 
parameter1={{Param|familiar|thing}}|
 
}}|
 
 
 
function3={{Function|
 
name={{#var:name}}|
 
aggregate={{#var:aggregate}}|
 
return_type={{#var:return_type}}|
 
return_also={{#var:return_also}}|
 
parameter1={{Param|skill|thing}}|
 
}}|
 
 
 
function4={{Function|
 
name={{#var:name}}|
 
aggregate={{#var:aggregate}}|
 
return_type={{#var:return_type}}|
 
return_also={{#var:return_also}}|
 
parameter1={{Param|string|thing}}|
 
p1desc={{pspan|thing}} is checked for trendiness|
 
}}|
 
 
 
function_description=This function checks to see if the {{pspan|thing}} is currently trendy. {{pspan|thing}} can be an item, familiar, skill. It can also be a string to check all categories. Using the string parameter is the only way to check a campground items. Bookshelf skills are checked by the skill parameter.</p>
 
 
 
<p>Fuzzy matching is not used for a string parameter so you need to spell it properly, including [http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references character entities]. Otherwise it will not match against the item, familiar or skill in the database.|
 
  
 
code1={{CodeSample|
 
code1={{CodeSample|
title=Code Samples|
+
title=Code Sample|
description=Ouputs which familiars can be used if you are on the Trendy Path.|
+
description=Examples of using format_date_time().|
 
code=
 
code=
 
<syntaxhighlight>
 
<syntaxhighlight>
if (my_path() == "Trendy") {
+
string input;
  foreach it in $familiars[]
+
string format;
      if (have_familiar(it) && is_trendy(it))
+
string informat;
        print("You can currently use familiar "+it+".", "blue");
+
 
}
+
input = today_to_string();
else print("You are not on the Trendy path.", "blue");
+
informat = "yyyyMMdd";
 +
format = "yyyy MM dd";
 +
print(input+" * "+format_date_time(informat, input, format));
 +
format = "yyyy MM dd hh:mm:ss";
 +
print(input+" * "+format_date_time(informat, input, format));
 +
input = time_to_string();
 +
print(input+" * "+format_date_time(informat, input, format));
 +
informat = "hh:mm:ss z";
 +
print(input+" * "+format_date_time(informat, input, format));
 
</syntaxhighlight>|
 
</syntaxhighlight>|
 
+
moreinfo=
 +
This is the output:
 +
<pre>
 +
20111206 * 2011 12 06
 +
20111206 * 2011 12 06 12:00:00
 +
11:43:35 EST * Bad parameter(s) passed to format_date_time
 +
11:43:35 EST * 1970 01 01 11:43:35
 +
</pre>
 
}}|
 
}}|
 
see_also={{SeeAlso|is_giftable|is_tradeable}}|
 
 
}}
 
}}
 +
{{SeeAlso|gameday_to_string|gameday_to_int|now_to_string|time_to_string}}
  
 
[[Category:Miscellaneous Functions]]
 
[[Category:Miscellaneous Functions]]

Revision as of 21:55, 6 December 2011

Function Syntax

string format_date_time(string inFormat ,string dtg ,string outFormat )

  • inFormat is how the input string is formatted.
  • dtg is the time to reformat.
  • outFormat is how the output string should be formatted.

Full information on SimpleDateFormat here.

Code Sample

Examples of using format_date_time().

string input;
string format;
string informat;

input = today_to_string();
informat = "yyyyMMdd";
format = "yyyy MM dd";
print(input+" * "+format_date_time(informat, input, format));
format = "yyyy MM dd hh:mm:ss";
print(input+" * "+format_date_time(informat, input, format));
input = time_to_string();
print(input+" * "+format_date_time(informat, input, format));
informat = "hh:mm:ss z";
print(input+" * "+format_date_time(informat, input, format));

This is the output:

20111206 * 2011 12 06
20111206 * 2011 12 06 12:00:00
11:43:35 EST * Bad parameter(s) passed to format_date_time
11:43:35 EST * 1970 01 01 11:43:35


See Also

gameday_to_string() | gameday_to_int() | now_to_string() | time_to_string()