Day of the week: Difference between revisions

added Ursala
m (Fixed lang tags.)
(added Ursala)
Line 971:
 
(Output same as UNIX Shell)
 
=={{header|Ursala}}==
 
A standard library, stt, provides basic date manipulation functions,
and is imported in this example. Unix era times denominated in seconds since
1969 (excluding leap seconds) are represented as natural numbers with
unlimited precision. Results are valid for the arbitrarily distant
future assuming the Gregorian calendar remains in force.
 
The algorithm relies on the string_to_time function converting a date
expressed as a character string to seconds without needing a weekday field in
the input, and the time_to_string function outputting the corresponding
date with the weekday included. The output is then filtered for Sundays.
 
<lang Ursala>
#import std
#import nat
#import stt
 
christmases = time_to_string* string_to_time*TS 'Dec 25 0:0:0 '-*@hS %nP* nrange/2008 2121
 
#show+
 
sunday_years = ~&zS sep` * =]'Sun'*~ christmases
</lang>
output:
<pre>
2011
2016
2022
2033
2039
2044
2050
2061
2067
2072
2078
2089
2095
2101
2107
2112
2118
</pre>
 
=={{header|Vedit macro language}}==
Anonymous user