Date manipulation

From Fōrmulæ wiki
Revision as of 13:29, 20 July 2019 by Admin (Talk | contribs) (Creation of page)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page is the answer to the task Date manipulation in the Rosetta Code.

Description (from Rosetta Code)

Task

Given the date string "March 7 2009 7:30pm EST", output the time 12 hours later in any human-readable format.

As extra credit, display the resulting time in a time zone different from your own.

Solution

Step 1. Creating the initial time

Fōrmulæ is highly internationalized software. The task requires to parse a time from a string in very localized and specific format. We prefer to get a lower score for this task in favor to show a more general form:

The initial time can be created as follows:

DateManiulation01.png

Explanation:

Time expressions in Fōrmulæ are never related to any any time zone. When creating the expression, one is defined in order to provide the time zone the rest of time components are referred to.

Visualizing Time expressions are, on the other hand, performed respect to the current time zone (the time zone of the computer where the program is running on). For the example, in

Step 2. Adding 12 hours

DateManiulation02.png

Step 3. Showing results

DateManiulation03 01.png

DateManiulation03 02.png

DateManiulation03 03.png