It is currently January 17th, 2019, 1:30 am

Simply working schedule depending on the system date

Get help with installing and using Rainmeter.
TheRadek
Posts: 3
Joined: January 2nd, 2019, 1:11 pm

Simply working schedule depending on the system date

TheRadek » January 2nd, 2019, 1:44 pm

Hello All,

I'm a new user, just installed the Rainmeter...

I do not need much....I have just a schedule of working hours in excel, I need only to have it on my screen depending on the current date ( system date)

I'm using Illustro. This is fine for me...I do not need more. Just an additional widget with my data....


I know already that I cannot do this directly from excel file, but how can I add a widget, write a script and from which kind of file?

Many thanks for help.

Regards from Poland ;)
Radek
User avatar
balala
Rainmeter Sage
Posts: 7426
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Simply working schedule depending on the system date

balala » January 2nd, 2019, 2:36 pm

TheRadek wrote:
January 2nd, 2019, 1:44 pm
I do not need much....I have just a schedule of working hours in excel, I need only to have it on my screen depending on the current date ( system date)
As you said is hard to take those information directly from the Excel file. But from a text file it can be easily got. How that Excel file is created / maintained? Could those information be exported to a text file?
TheRadek
Posts: 3
Joined: January 2nd, 2019, 1:11 pm

Re: Simply working schedule depending on the system date

TheRadek » January 2nd, 2019, 8:48 pm

balala wrote:
January 2nd, 2019, 2:36 pm
How that Excel file is created / maintained?
I have Office 365 Pro, file was created manually, so all the data I fill by hand in a following manner:

DATE | Day | From | To | sum
02-01-2019 | Thuesday | 7:00 | 15:00 | 8
etc...

balala wrote:
January 2nd, 2019, 2:36 pm
Could those information be exported to a text file?
I guess so....all the files extensions supported by the office 365 for excel are possible....just let me know what file would the the best.

The idea of the widget is just a simple information:
What date is currently -> then a formula need to find the row of the date and just show the day and hours from/to...

P.S. In excel I could joind the text, so the result of the final excel widget is like: 7-15 ( =7&"-"&15)

Many thanks for the support.
User avatar
balala
Rainmeter Sage
Posts: 7426
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Simply working schedule depending on the system date

balala » January 2nd, 2019, 8:57 pm

TheRadek wrote:
January 2nd, 2019, 8:48 pm
just let me know what file would the the best.
Ok, export the file in simple .txt format and upload it here. We'll use WebParser measures to read the content and eventually we'll need a small .lua script to get the needed information. But first I'd need to see how does that file looks like.
TheRadek
Posts: 3
Joined: January 2nd, 2019, 1:11 pm

Re: Simply working schedule depending on the system date

TheRadek » January 3rd, 2019, 7:23 am

balala wrote:
January 2nd, 2019, 8:57 pm
export the file in simple .txt format and upload it here.
Here it is:
  • sty.19 Od Do Ile
    01.01.2019 wtorek 0 0 0,00
    02.01.2019 środa 12 20 8,00
    03.01.2019 czwartek 12 20 8,00
    04.01.2019 piątek 0 0 0,00
    05.01.2019 sobota 9 19 10,00
    06.01.2019 niedziela 0 0 0,00
    07.01.2019 poniedziałek 14 22 8,00
    08.01.2019 wtorek 14 21 7,00
    09.01.2019 środa 0 0 0,00
    10.01.2019 czwartek 10 19 9,00
    11.01.2019 piątek 0 0 0,00
    12.01.2019 sobota 10 19 9,00
    13.01.2019 niedziela 0 0 0,00
    14.01.2019 poniedziałek 14 22 8,00
    15.01.2019 wtorek 0 0 0,00
    16.01.2019 środa 11 20 9,00
    17.01.2019 czwartek 0 0 0,00
    18.01.2019 piątek 11 19 8,00
    19.01.2019 sobota 0 0 0,00
    20.01.2019 niedziela 0 0 0,00
    21.01.2019 poniedziałek 14 22 8,00
    22.01.2019 wtorek 0 0 0,00
    23.01.2019 środa 11 19 8,00
    24.01.2019 czwartek 0 0 0,00
    25.01.2019 piątek 9 18 9,00
    26.01.2019 sobota 0 0 0,00
    27.01.2019 niedziela 0 0 0,00
    28.01.2019 poniedziałek 11 19 8,00
    29.01.2019 wtorek 14 22 8,00
    30.01.2019 środa 0 0 0,00
    31.01.2019 czwartek 10 19 9,00
Or use THIS link.

P.S. Sorry, is in polish ;)
User avatar
balala
Rainmeter Sage
Posts: 7426
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Simply working schedule depending on the system date

balala » January 3rd, 2019, 7:10 pm

TheRadek wrote:
January 3rd, 2019, 7:23 am
P.S. Sorry, is in polish ;)
Doesn't matter too much.
So, here is a solution. Create a skin and paste the following content:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[MeasureLuaScript]
Measure=Script
ScriptFile=#@#Events.lua
Disabled=1

[MeterEvent]
Meter=STRING
X=0
Y=0
Padding=15,5,15,5
FontColor=220,220,220
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=[&MeasureLuaScript:GetEvent('Today')]
DynamicVariables=1
See that this code is extremely simple. It uses inline LUA (through the Text option of the [MeterEvent] String meter), a new approach to lua codes. The [MeasureLuaScript] measure is disabled, however it'll work.
As you can see in the [MeasureLuaScript] measure, this code needs an Events.lua file, which has to be placed into the @Resources folder. Create a such named file there and paste the following content:

Code: Select all

function file_exists(file)
	local f = io.open(file, 'r')
	if f then f:close() end
	return f ~= nil
end

function lines_from(file)
	if not file_exists(file) then return {} end
	lines = {}
	for line in io.lines(file) do 
		lines[#lines + 1] = line
	end
	return lines
end

function Date(Item)
	return string.match(Item, '(%d%d.%d%d.%d%d%d%d)')
end

function Event(Item)
	return string.match(Item, '%d%d.%d%d.%d%d%d%d (.+)')
end

function GetEvent(ReqDate)
	local Ret, Resources = '', tostring(SKIN:GetVariable('@'))
	Resources = string.gsub(Resources, '\\', '//')
	if string.lower(ReqDate) == 'today' then
		ReqDate = tostring(os.date('%d'))..'.'..tostring(os.date('%m'))..'.'..tostring(os.date('%Y'))
	end
	local Dates = lines_from(Resources..'Events.inc')
	local DS, ES = {}, {}
	for i = 1,#Dates do
		DS[i], ES[i] = Date(Dates[i]), Event(Dates[i])
	end
	i = 0
	repeat
		i = i + 1
		if (DS[i] == ReqDate) then
			Ret = ES[i]
		end
	until (DS[i] == nil) or (Ret ~= '')
	if Ret ~= '' then
		return Ret
	else
		return 'Inexistent date'
	end
end
This file reads the events (sorry, I didn't know how to name them, so ended up naming them events, hope it's ok) from an Events.inc file, also placed into the @Resources folder. Create it and paste the content provided by you, into it.
Now a few words about how to use the skin: as you can see the [MeterEvent] String meter returns the event, but you have to provide a variable (into its Text option). This variable can be either a date (in which case the event of the provided date will be shown), or the Today expression (case insensitive). Obviously in this last case the event of today is shown (probably this is what you want).
If you want to provide a date, you have to use the DD.MM.YYYY format. It seems (and I hope) this is the widely used date format in Polish.
The skin (and the .lua script) can be modified to show, beside today's event, tomorrow's, yesterday's or so on, event. Let me know if you need any of these events, too.
Please check the above code and let me know if you've succeeded making it to properly work.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3129
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Simply working schedule depending on the system date

eclectic-tech » January 3rd, 2019, 8:10 pm

Alternative Webparser Method

balala mentioned using a Webparser plugin, but opted for lua, which is good for this case, due to more than 99 items are in the schedule file (99 is the limit of indexes in most cases).

I was working on a skin that uses illustro style and can show all days in the month (you need to expand measures and meters, I only coded the first 3) using StringIndex2 to overcome the 99 item limit when balala posted the above reply.

Just to allow options, I attached a rmskin package which show the first 3 days and can be expanded to show more using copy and paste technique. Forgive my 'Googled' Title translation 'Work Schedule'!
workschedule.png
Note: I saved your example text as '01Schedule.txt' in the @Resources folder. '01' represents the current month; name February '02Schedule.txt'
IMPORTANT: I also added a carriage return to the last line of that text file, so the webparser can determine the last entry.

The webparser measure will read each line of the file, then use StringIndex2 to pick out all of the details for each line. It will return each item in a separate index (8 total for each day); day, month, year, weekday, start time, end time, total hours, and I not sure what the last value after the comma is used for???

I thought I would post what I had to show an alternative and let the OP decide.

I would agree that the lua method will require less code to retrieve the information, but about the same amount to display it.
You do not have the required permissions to view the files attached to this post.