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
It is currently April 25th, 2024, 12:07 pm
Simply working schedule depending on the system date
-
- Posts: 3
- Joined: January 2nd, 2019, 1:11 pm
-
- Rainmeter Sage
- Posts: 16168
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Simply working schedule depending on the 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?
-
- Posts: 3
- Joined: January 2nd, 2019, 1:11 pm
Re: Simply working schedule depending on the system date
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...
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.
-
- Rainmeter Sage
- Posts: 16168
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Simply working schedule depending on the system date
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.
-
- Posts: 3
- Joined: January 2nd, 2019, 1:11 pm
Re: Simply working schedule depending on the system date
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
P.S. Sorry, is in polish
-
- Rainmeter Sage
- Posts: 16168
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Simply working schedule depending on the system date
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
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
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.
-
- Rainmeter Sage
- Posts: 5406
- Joined: April 12th, 2012, 9:40 pm
- Location: Cedar Point, Ohio, USA
Re: Simply working schedule depending on the system date
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'! 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.
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'! 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.
:: My DA Gallery :: Rainmeter DA Gallery :: Rainmeter Workshops :: Rainmeter Documentation :: BBCode Guide ::