Archive: Time plugin


Time plugin
Features:
- Get local time
- Set local time
- Get file/directory creation, last write, last access times
- Set file/directory creation, last write, last access times

Notes:
- All times in "dd.MM.yyyy hh:mm:ss" format (e.g. "01.01.2006 23:59:59")
- Win95/Win98/WinMe: Time set for directory is not supported

!! If you know assembler you can help to implement time set for directory in Win95/Win98/WinMe: link


"Time" plugin v1.0


nice one


Changes:
-New: "CompareTime" compares two times


"Time" plugin v1.1


Fixed: "SetLocalTime" daylight saving time problem
Changed: "CompareTime" replaced with "MathTime"
Added: UTC support ("GetLocalTimeUTC", "SetLocalTimeUTC", "GetFileTimeUTC",
           "SetFileTimeUTC")
New: "MathTime" -mathematical operations with times.
           -calculate day of the week,
           -calculate date after 60 days,
           -calculate how many days between dates,
           -compare dates,
           -calculate how many days in 1234567890 seconds ...
New: "TimeString" -get times from time string


"Time" plugin v1.2


Fixed: "MathTime" inaccuracy of day/month->date conversion in one day/month


"Time" plugin v1.3


Not sure if it would work for this plugin or not, but here's a few suggestions that would be nice to have:

1. GetWeekdayName - a function to allow the user to input a time and get back the weekday name (ie "Sunday")

2. GetWeekdayNumber - same as above, but return the weekday number. (ie Sunday=1, Monday=2, etc.)

3. GetMondayDate - input a date and have the system return the Monday from that week. For example, if you input 1/4/2005 (a Wednesday), you would get an output of 1/2/2005 (a Monday).

:cool:


Name "Output"
OutFile "Output.exe"

Section
#GetWeekdayNumber:
time::MathTime "day(29.12.2005 0:0:0) + 5 % 7 =" .r0
MessageBox MB_OK 'GetWeekdayNumber$\n$$0={$0}'


#GetWeekdayName:
time::MathTime "day(29.12.2005 0:0:0) + 5 % 7 =" .r0
StrCmp $0 1 0 +2
StrCpy $0 Monday
StrCmp $0 2 0 +2
StrCpy $0 Tuesday
StrCmp $0 3 0 +2
StrCpy $0 Wednesday
StrCmp $0 4 0 +2
StrCpy $0 Thursday
StrCmp $0 5 0 +2
StrCpy $0 Friday
StrCmp $0 6 0 +2
StrCpy $0 Saturday
StrCmp $0 0 0 +2
StrCpy $0 Sunday
MessageBox MB_OK 'GetWeekdayName$\n$$0={$0}'


#GetMondayDate:
!define Monday 1
!define Tuesday 2
!define Wednesday 3
!define Thursday 4
!define Friday 5
!define Saturday 6
!define Sunday 7 #!define Sunday 0

time::MathTime "day(29.12.2005 0:0:0) + 5 % 7 =" .r0
time::MathTime "day(29.12.2005 0:0:0) - $0 + ${Monday} = date" .r0
MessageBox MB_OK 'GetMondayDate$\n$$0={$0}'
SectionEnd

Added: "MathTime" now can parse negative values ("-10 + -20 =" returns -30)


"Time" plugin v1.4


D'OH! I feel like such a dolt! I looked over the readme doc several times and didn't see the example about getting the day of the week until you posted your reply! :tinfoil:

Thanks for posting the example. This should work quite nicely! :D


Fixed: time::MathTime now error output is "" not "-1" (negative results allowed).
Changed: time::SetFileTime now don't changes any file time if error appeared.
Updated: example "Compare times".
Updated: "ConvFunc.h" to v1.6.
Changed: Now plugin used header "Time.nsh" for custom user variables and
              better compile errors check.

Update from previous versions:
         - Insert line in script:
            !include "Time.nsh"
         - Replace:
            time::SetLocalTime -> ${time::SetLocalTime} ...
         - Replace:
            .r0 -> $0, .r1 -> $1 ... .R0 -> $R0, .R1 -> $R1 ...

"Time" plugin v1.5


Hi Instructor,

I tried something like

${time::MathTime} "day(27.03.2006 12:00:00) - day(15.05.2006 17:00:00) = day"

and got "" (error). You wrote "negative results allowed" (post above), so it should be something like "-50" (or nearby).


Rough result:
"day(27.03.2006 12:00:00) - day(15.05.2006 17:00:00) ="

I'll check later for accurate negative result possibility:
"second(27.03.2006 12:00:00) - second(15.05.2006 17:00:00) = day"


Added: "MathTime" now can accept negative values in the result conversion -
            after "=", but except "= date".


"Time" plugin v1.6


Hi Instructor,

1. thanks!

2. "-v" please. Does that mean I can use "= second" now and compare using IntCmp 86400 (instead of 1)?


"-v" please. Does that mean I can use "= second" now and compare using IntCmp 86400 (instead of 1)?
I don't understand. The new version allow you to write the next expression
"second(27.03.2000 12:00:00) - second(15.05.2006 17:00:00) = day"
Result will be "-2240" - days between dates.

I am unable to get time.dll to unload, even with

Function .onGUIend
RMDir /r $PLUGINSDIR
FunctionEnd

${time::Unload}

Thanks for the plugin.

I am a beginner and would like to make a simple exe which sets local date back to 10 years and another one which sets the actual date.

I successfully created an exe which sets date back but don't know how to restore the actual date (and time).

If someone could help I would really appreciate it.

Thanks
tpr

Edit: problem solved, I've overlooked TimeTest.nsi


Unicode NSIS

Hello Instructor,

I hope you are still actively developing the Time plug-in?
Because, I am (we are) looking for this plug-in, recompiled to work with Unicode NSIS.
It would be really appreciated, as we are in need of a fair few plug-ins with Unicode NSIS support!

Link to Unicode NSIS homepage: scratchpaper.com/home
Link our project: portableapps.com/node/21879

Thanx a lot, in advance !


Added: full unicode support on NSIS Unicode.

Time plugin v2.0