Group Abstract Group Abstract

Message Boards Message Boards

My “Today's Template” using Mathematica?

Is there a way to recreate what I’m currently doing in Microsoft Word everyday, using the Wolfram Langue and/OR Mathematica to a CDF Printable Format? It’s fairly simple and strait forward. It is a template I use and print for a magnetic whiteboard I use to do videos.

The first number is the year month day displayed in an single eight digit number, the second area is the day of the year / days left in the year, the third is the week number with the day of the week following the ISO standard, the fourth and middle area is the day of the week, month and day, and the year, the fifth is the season and the number of days in that season/ and the days remaining (with the week of that season), the sixth is the current quarter and the days in that quarter / and the days remaining (with the week of that quarter).

This “todays template” works as Monday being the first day of the week.

For obvious reasons I would like to have it be generated automatically, for less obvious reasons I would like it to be formatted and displayed as in the image (if I am able to successfully upload/share it to the Wolfram Community site).

Daily Templage

Now I’m sure this is a simple thing to accomplish but as someone trying to depend less upon Microsoft technologies and more upon Wolfram’s I would greatly appreciate any direction. while this is something I will be attempting to recreate on my own eventually, as I become more accomplished in Mathematica and more specifically the wolfram language, and because the Computable Document Format is just that, computable, would it be possible to have the calculations automatically update within this document format itself triggered from the system clock on my computer?

Or is there some other method someone could suggest? Something that possibly I have not yet considered like doing the calculations in Mathematica or wolfram alfa and having and them just share the data itself to be displayed in template that I've already created on some other document type.

POSTED BY: Brian Woytovich
15 Replies

Actually I think I misspoke and miscalculated the Days, because it just happened to be in the middle of the season when I checked the code, so when I thought it was giving me the number of days of spring, on this link and compared it to the code, it was actually giving me the number of days REMAINING. So, that being said, the day of spring is not off, but rather those number of days remaining. For instance we show that there are 93 days in spring, not technically, but according to any calendar the way it records it. So, I am not sure how to deal with this if we have to round something or do something in the code to adjust for this. And to your point of starting on the day as Zero, no we actually start as day one, but I think the above explanation explains why I was not explaining what I saw correctly. Hope this clears it up and and makes it more clear as to how we can adjust the code in order make this more inline with any store bought calendar.

enter image description here

Thanks again, and as usual I am starting to really appreciate the code, and have already been feeding it past dates to check on what we call Chrono Labeling records for past dates. Because I can put in any date and it works great!

Thank you as always,

Brian!

POSTED BY: Brian Woytovich
POSTED BY: Chad Knutson
POSTED BY: Brian Woytovich
Posted 9 years ago
POSTED BY: Updating Name

Brian: I did not think the partial solution was neing used. I had continued some work on your question, did not post. Currently don't have access to that code. When I find it I will post from where I stopped work.

But I had same or similar questions as Sander. And the seasons cross years. Depends on where on Earth so to work every where your code would need location if not accessible then set a default location.

POSTED BY: Hans Michel

Ok, thanks Sander, I will take a look at this further, thanks for the feedback!

POSTED BY: Brian Woytovich

If I execute my code in 11.1 it executes without any errors, make sure you have a fresh kernel without old definitions still in memory or such...

How do you define the seasons? there are multiple definitions in the world, and some that even change per year... without a definition it is gonna be hard...

POSTED BY: Sander Huisman
POSTED BY: Brian Woytovich

This is great! Thank you both Sander and Brain and to whomever else joins in the assistance with creating this template. I did not expect so much help but only maybe some direction, but this is great! Actually I was already answering Sander by the time Brian had written in but had posted it many hours later before I had a chance to look at yours Brian, the formatting and placement looks great. I'll have to look at the code more closely, and because I am so new it will take me a while, but I like the different approaches so i can better learn this language. Have not yet looked at it in detail but in both cases I am at least getting a better idea. And if anyone else wants to improve upon this even more, it will be welcomed :).

Thanks so much for the community's help on this!

So, currently every day I figure out the numbers by looking at my calendar and adding or subtracting by hand, and only continue to do this because it's become the way I have always done it up to this point. Obviously even if I just have Mathematica give me the numbers each day it would be easier than doing it all myself, and I could even put it myself in a template, but I like the direction that the those who have answered are taking. To keep us on track with what the numbers should be, as of today, I updated what it should read for TODAY (noticing the first image I think was off a bit) figuring it out myself, and I know even using Wolfram Alpha probably would be easier then counting but like I said, you know how you get into the habit of things :(.

Anyway, TODAY's template I think should read the following numbers and also this time included a line through what would be nice but not necessary and what I think my be difficult because of my unique way of calculating this as a "week", but all the other numbers should be exact and easy to calculate each and every day updated, automatically.

Today's Template for Firday, April 29th, 2016 - FROM WORD

POSTED BY: Brian Woytovich
POSTED BY: Brian Woytovich

Brian:

I don't have much time to give a proper solution; so as time is ticking I will put what I have so far.

SetSystemOptions["DataOptions" -> "ReturnQuantities" -> False];

ISOWeek[x_] := 
  Module[{d2}, 
   d2 = DateList[{ToExpression[
       DateString[
        DatePlus[
         x, {(-(Flatten[
                Position[{"Sunday", "Monday", "Tuesday", "Wednesday", 
                  "Thursday", "Friday", "Saturday"}, 
                 DateString[DatePlus[x, {-1, "Day"}], {"DayName"}], 
                 1]])[[1]] + 4), "Day"}], "Year"]], 1, 3, 0, 0, 0}]; 
   IntegerPart[(DateDifference[d2, x] + 
       Flatten[Position[{"Sunday", "Monday", "Tuesday", "Wednesday", 
           "Thursday", "Friday", "Saturday"}, 
          DateString[d2, {"DayName"}], 1]][[1]] + 5)/7]];

ISODay = Function[{date}, 
   Flatten[Position[{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"},
       DateString[date, {"DayNameShort"}], 1]][[1]]];

Grid[{
  {
   Item[Style[
     DateString[DateList[], {"Year", "", "Month", "", "Day"}], 
     FontFamily -> "Arial Black", FontWeight -> "Black", 
     FontSize -> 32], Alignment -> Center],
   Item[Style[
     StringJoin[
      ToString[
       IntegerPart[DateDifference[{First[DateList[]]}, DateList[]]]], 
      " / ", ToString[IntegerPart[
            DateDifference[ DateList[], {Plus[First[DateList[]], 1]}]]]],
      FontSize -> 28, FontFamily -> "Arial", FontWeight -> Bold], 
    Alignment -> Center],
   Item[Style[
     Row[{Style[StringJoin["WK", ToString[ISOWeek[DateList[]]]], Red],
        Style[StringJoin["-", 
         ToString[
          NumberForm[ISODay[DateList[]], 
           NumberPadding -> {"0", ""}]]], Black]}], FontSize -> 30, 
     FontFamily -> "Arial Black", FontWeight -> Bold], 
    Alignment -> Center]
   },
  {
   Item[Style[
     DateString[
      DateList[], {"DayName", ", ", "MonthName", " ", "Day", "th, ", 
       "Year"}], FontSize -> 40, FontFamily -> "Calibri", 
     FontWeight -> Bold, FontColor -> White, Background -> Black], 
    Alignment -> Center, Background -> Black], SpanFromLeft, 
   SpanFromLeft
   }, {
   Row[
    {
     Item[
      Style["Spring 30/63 (2nd)", FontSize -> 24, 
       FontFamily -> "Arial", FontWeight -> Bold], 
      Alignment -> Center], Spacer[50], 
     Item[Style[
       StringJoin[DateString[DateList[], "Quarter"], "nd", 
        " Quarter ", "18/73 (3rd)"], FontSize -> 24, 
       FontFamily -> "Arial", FontWeight -> Bold], Alignment -> Center]
     }, Alignment -> Center , Frame -> False
     ], SpanFromLeft, SpanFromLeft}
  },
  Frame -> True, FrameStyle -> Thickness[5], Spacings -> {2, 5}]

Which would give

enter image description here

The Seasons, Quarters, and dividers need more work. I had a version with Overlay[Grid[]...]. But that was unstable interns of screen resizing. There used to be a package that calculated Seasons

see Scientific Astronomer http://library.wolfram.com/infocenter/Conferences/372/ I attempted to get as close to your original fonts. It would be easier to explicitly state them. My font matching skills are rusty. I'll come back to this later.

POSTED BY: Hans Michel

I'm pretty sure you have an older version of Mathematica. I assumed the newest. 2 options: update or change the code...

POSTED BY: Sander Huisman

Thank you, Sander Huisman! Now just to let you know, I am new to the Wolfram Language and I am currently reading; “An Elementary Introduction to the Wolfram Language.” I am extremely impressed with the speed of this community to produce the code requested. Using the code you have provided, I get the following output…

enter image description here

As you can see, the output is different from what you have displayed in you last message. Is there a way to convert it to what you show or am I doing something wrong? Again, I apologize that I’m so green at this! The members in this community have been outstanding with respect to the four questions I have asked to date.

It’s going to be a learning curve for me and my friends as we now try to move our ideas to the Wolfram Cloud while we slowly create each of the solutions we need using the Wolfram Language.

This template is just one of many components of a greater project that I have been working on for over two decades. When I see the code you have written, I am better able to deconstruct it as I learn the language and apply it to other parts of our ongoing project. This question, as it relates to a template for our white board, will move us more towards Wolfram technologies and away from products such as Word, Excel and PowerPoint.

These are probably simple problems for many in this community. I have read some of the impressive profiles of members but for those of us working on our own projects with little background in the Wolfram Language it seems a bit daunting, but we are in this for the long haul!

Thank you,

Brian

POSTED BY: Brian Woytovich

Hi Brian,

I made a good start:

ClearAll[StNdRd,CreateTemplate]
StNdRd[n_String]:=If[IntegerQ[ToExpression[n]],StNdRd[ToExpression[n]],""]
StNdRd[n_Integer]:=If[3<n<21,"th",Switch[Mod[n,10],1,"st",2,"nd",3,"rd",_,"th"]]
CreateTemplate[time_:Now]:=Module[{t,top,middle,dayofyear,totaldays,week,dayofweek,ordinal,bottom2,Quarterstart,dayofquarter,Quarterend,daysinquarter},
t=Take[DateList[time],3];
dayofyear=DateValue[t,"ISOYearDay"];
totaldays=If[LeapYearQ[t],366,365];
week=DateString[t,"WeekShort"];
dayofweek=DateString[t,"ISOWeekDay"];
top={Style[DateString[t,{"Year","Month","Day"}],Bold],Row[{ToString[dayofyear],"/",ToString[totaldays-dayofyear]}],Row[{Style["WK"<>week,Red,Bold],Style["-"<>dayofweek,Bold]}]};
top={Row[top," | "],SpanFromLeft};
ordinal=StNdRd[DateValue[t,"Day"]];
middle={Style[DateString[t,{"DayName", ", ","MonthName"," ","DayShort",ordinal,", ","Year"}],White],SpanFromLeft};
Quarterstart=Take[DateList[t],2];
Quarterstart={First[Quarterstart],Floor[Last[Quarterstart]-1,3]+1,1};
Quarterend=Quarterstart;
Quarterend[[2]]+=3;
Quarterend=DateList[Quarterend];
daysinquarter=QuantityMagnitude[DateDifference[Quarterstart,Quarterend],"Day"];
dayofquarter=QuantityMagnitude[DateDifference[Quarterstart,t,"Day"],"Day"]+1;
bottom2=Column[{Row[{DateString[t,{"Quarter"}]<> StNdRd[DateValue[t,"Quarter"]]<>" Quarter ",dayofquarter,"/",daysinquarter-dayofquarter}],Row[{"(",daysinquarter," Days"," / 13 Weeks)"}]},"Center"];
Grid[{top,middle,{Null,bottom2}},Frame->All,Background->{None,{None,Black,None}}]
]

To try out:

CreateTemplate[]
CreateTemplate[{2016, 4, 18}]
CreateTemplate[{1987, 7, 2}]

Giving:

enter image description here

I will leave you with implementation the seasons part, the font-choices, sizes, colors, and exact styling...

POSTED BY: Sander Huisman

Hi Brian,

Pretty much all the pieces of text can be generated using DateString. For the remaining dates of the year/quarter I suggest you use DateDifference. You can use a Grid construct to format it like you have above. It can contain anything and you can set the background to White/Black as you have, also you can merge the cells using SpanFromLeft. You can use Style to style the various colors. If I have some more time, I can give it a try.

--SH

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard