Easy way to show tomorrows day of the week (or the next) in Minimalist Text

353 views
Skip to first unread message

Wes Lydon

unread,
May 10, 2013, 10:17:09 AM5/10/13
to tas...@googlegroups.com
I spent a while looking for a decent way to do this and came up with a couple really cumbersome methods. I think this is an improvement.

I was trying to set a Minimalist Text widget to display info in the following format:

TOMSweatherTEMP|TOMNweatherTEMP

TOMS=Day of week tomorrow // For the sake of this example, lets assume today is Monday. We want this to Equal TUE
TOMN=Day of week after that // For the sake of this example, lets assume today is Monday. We want this to Equal WED

My solution 

Tasker Profile:DayofTom
From: 00:02 - 00:03
Task: DayofTomorrow

Task: DayofTomorrow
  1. Variable Set: %TOMS to %TIMES + 86400 // This sets variable %TOMS to tomorrows date in seconds
  2. Variable Convert: %TOMS Function Seconds to Long Date // This sets variable %TOMS to a long form date
  3. Variable Split: %TOMS Splitter , // This makes the long date split into multiple variables where a "," is present. This creates 3 variables, %TOMS1, %TOMS2, %TOMS3. We will be using %TOMS1, which has become "Tuesday"
  4. Variable Section: Name %TOMS1 From 1 Length 3 // Because I wanted to show a short day name (Tue, not Tuesday), this action discards any characters outside of the first 3. Now we just need to send the variable to Minimalist Text. Do not include this action if you want the full day name used
  5. Minimalist Text: Configuration TOMS = %TOMS1 // This action is available through plugins. Set "variable name" to TOMS (this is what is sent to Minimalist Text). Set Variable Content to %TOMS1 (the local variable)

Now go to Minimalist Text and in the widget of your choice and add "Locale Variable" with Variable Name TOMS.

You're DONE!

To get the day after tomorrow: 
Create a new profile: "DayofTomNext"
Create a new Task: "DayofTomNext"
Then use the exact same process as above, but add 1728000 instead of 86400, and replace TOMS with TOMN.

Hope this helps anyone that tries to do this later.

Rich D

unread,
May 10, 2013, 9:30:12 PM5/10/13
to tas...@googlegroups.com

> I spent a while looking for a decent way to do this and came up with a couple really cumbersome methods. I think this is an improvement.
>

Nice work... I did the exact same thing when I built my date picker. It lets tasker do all the Calender work. 

Rich..

UncleMike

unread,
May 10, 2013, 10:27:43 PM5/10/13
to tas...@googlegroups.com
Try this: (description below, xml attached)

Example:
Perform Task getFormattedDate par1:%TIMES par2:ddd would return a three-character day name for today (e.g. Fri)

Example:
Variable Set %TOMS %TIMES + 86400
Perform Task par1:%TOMS par2:dddd, mmmm dd, yyyy would return the day name, month, day and year for tomorrow (e.g. Monday, April 15, 2013)

getFormattedDate (54)
Run Both Together
A1: JavaScriptlet [ Code:var gsMonthNames = new Array(
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December'
);

var gsDayNames = new Array(
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday'
);

var d = new Date(par[0] * 1000);
var f = par[1];

var formatteddate = f.replace(/(yyyy|yy|mmmm|mmm|mm|dddd|ddd|dd|hh|nn|ss|a\/p)/gi,
    function($1)
    {
        switch ($1)
        {
        case 'yyyy': return d.getFullYear();
        case 'yy':   return ('0' + d.getFullYear()).slice(-2);
        case 'mmmm': return gsMonthNames[d.getMonth()];
        case 'mmm':  return gsMonthNames[d.getMonth()].slice(0,3);
        case 'mm':   return ('0' + (d.getMonth() + 1)).slice(-2);
        case 'dddd': return gsDayNames[d.getDay()];
        case 'ddd':  return gsDayNames[d.getDay()].slice(0,3);
        case 'dd':   return ('0' + d.getDate()).slice(-2);
        case 'hh':   return ('0' + ((h = d.getHours() % 12) ? h : 12)).slice(-2);
        case 'nn':   return ('0' + d.getMinutes()).slice(-2);
        case 'ss':   return ('0' + d.getSeconds()).slice(-2);
        case 'a/p':  return d.getHours() < 12 ? 'a' : 'p';
        }
    }
); Libraries:45 Auto Exit:On Timeout (Seconds):45 ] 
A2: Return [ Value:%formatteddate Stop:On ] 


getFormattedDate.tsk.xml

Rich D

unread,
May 11, 2013, 8:43:52 AM5/11/13
to tas...@googlegroups.com

> Try this: (description below, xml attached)

Well that's handy....  very nice...  :)

Reply all
Reply to author
Forward
0 new messages