[87] Relative Year

pull/877/head
meisnate12 3 years ago
parent 97f874067c
commit a3aba5472d

@ -1 +1 @@
1.16.5-develop86 1.16.5-develop87

@ -1597,6 +1597,10 @@ Creates a collection for each number defined.
<td><strong>Default:</strong> 1</td> <td><strong>Default:</strong> 1</td>
</tr> </tr>
</table> </table>
<ul>
<li><strong><code>starting</code> and <code>ending</code> can also have the value <code>current_year</code></strong></li>
<li><strong>You can also use a value relative to the <code>current_year</code> by doing <code>current_year-5</code></strong></li>
</ul>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -1644,7 +1648,7 @@ Creates a collection for each item in the list defined .
</tr> </tr>
<tr> <tr>
<th>Default Template</th> <th>Default Template</th>
<td>**None**</td> <td><strong>None</strong></td>
</tr> </tr>
</table> </table>

@ -457,12 +457,14 @@ class MetadataFile(DataFile):
else: else:
raise Failed(f"Config Error: {map_name} data attribute not found") raise Failed(f"Config Error: {map_name} data attribute not found")
number_methods = {nm.lower(): nm for nm in dynamic_data} number_methods = {nm.lower(): nm for nm in dynamic_data}
if "starting" in number_methods and dynamic_data[number_methods["starting"]] == "current_year": if "starting" in number_methods and str(dynamic_data[number_methods["starting"]]).startswith("current_year"):
starting = datetime.now().year year_values = str(dynamic_data[number_methods["starting"]]).split("-")
starting = datetime.now().year - (0 if len(year_values) == 1 else int(year_values[1].strip()))
else: else:
starting = util.parse("Config", "starting", dynamic_data, parent=f"{map_name} data", methods=number_methods, datatype="int", default=0, minimum=0) starting = util.parse("Config", "starting", dynamic_data, parent=f"{map_name} data", methods=number_methods, datatype="int", default=0, minimum=0)
if "ending" in number_methods and dynamic_data[number_methods["ending"]] == "current_year": if "ending" in number_methods and str(dynamic_data[number_methods["ending"]]).startswith("current_year"):
ending = datetime.now().year year_values = str(dynamic_data[number_methods["ending"]]).split("-")
ending = datetime.now().year - (0 if len(year_values) == 1 else int(year_values[1].strip()))
else: else:
ending = util.parse("Config", "ending", dynamic_data, parent=f"{map_name} data", methods=number_methods, datatype="int", default=0, minimum=1) ending = util.parse("Config", "ending", dynamic_data, parent=f"{map_name} data", methods=number_methods, datatype="int", default=0, minimum=1)
increment = util.parse("Config", "increment", dynamic_data, parent=f"{map_name} data", methods=number_methods, datatype="int", default=1, minimum=1) increment = util.parse("Config", "increment", dynamic_data, parent=f"{map_name} data", methods=number_methods, datatype="int", default=1, minimum=1)

Loading…
Cancel
Save