Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
a2cf0416
Commit
a2cf0416
authored
25 years ago
by
Mirar (Pontus Hagland)
Browse files
Options
Downloads
Patches
Plain Diff
print_month added
Rev: lib/modules/Calendar.pmod/module.pmod:1.3
parent
c995eb7c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/modules/Calendar.pmod/module.pmod
+45
-44
45 additions, 44 deletions
lib/modules/Calendar.pmod/module.pmod
with
45 additions
and
44 deletions
lib/modules/Calendar.pmod/module.pmod
+
45
−
44
View file @
a2cf0416
...
...
@@ -4,50 +4,6 @@
//! This module implements calendar calculations, and base classes
//! for time units.
//!
//! example program:
//! <pre>
//! void write_month(object m)
//! {
//! object w;
//! object today;
//!
//! today=function_object(object_program(m))->Day();
//!
//! write(sprintf(" %|28s\n",
//! Simulate.capitalize(m->name()+" ")
//! +m->year()->name()));
//!
//! w=m->day(1)->week();
//!
//! write(" ");
//! foreach (Array.map(w->days(),w->day)->week_day_name(),string n)
//! write(sprintf("%3s ",n[0..2]));
//! write("\n");
//!
//! do
//! {
//! array a;
//! object d;
//! a=Array.map(Array.map(w->days(),w->day),
//! lambda(object d,object m)
//! { if (d->month()!=m) return 0; else return d; },m);
//!
//! write(sprintf("%3s ",w->name()));
//! foreach (a,d)
//! if (d)
//! if (d!=today) write(sprintf(" %2d ",d->month_day()));
//! else write(sprintf(">%2d<",d->month_day()));
//! else write(" ");
//!
//! write("\n");
//! w++;
//! }
//! while (w->day(0)->month()==m);
//! }
//! </pre>
//! call with, for example,
//! <tt>write_month(Calendar.Swedish.Month());</tt>.
//!
//! class time_unit
//!
//! method array(string) lesser()
...
...
@@ -232,3 +188,48 @@ string datetime_short_name(int|void unix_time)
t->year, t->month, t->day,
t->hour, t->minute, t->second);
}
string print_month(void|object month,void|mapping options)
{
object w;
object today;
string res="";
if (!month) // resolv thing here is to avoid compile-time resolve
month=master()->resolv("Calendar")["Gregorian"]["Month"]();
today=function_object(object_program(month))->Day();
res=sprintf(" %|28s\n",
String.capitalize(month->name()+" ")
+month->year()->name());
w=month->day(1)->week();
res+=" ";
foreach (Array.map(w->days(),w->day)->week_day_name(),string n)
res+=sprintf("%3s ",n[0..2]);
res+="\n";
do
{
array a;
object d;
a=Array.map(Array.map(w->days(),w->day),
lambda(object d)
{ if (d->month()!=month) return 0; else return d; });
res+=sprintf("%3s ",w->name());
foreach (a,d)
if (d)
if (d!=today) res+=sprintf(" %2d ",d->month_day());
else res+=sprintf(">%2d<",d->month_day());
else res+=" ";
res+="\n";
w++;
}
while (w->day(0)->month()==month);
return res;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment