forked from Ixiko/AHK-libs-and-classes-collection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGetWeekDay_TwoLang.ahk
69 lines (49 loc) · 2.15 KB
/
GetWeekDay_TwoLang.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
; ===================================================================================
; AHK Version ...: AHK_L 1.1.14.03 x64 Unicode
; Win Version ...: Windows 7 Professional x64 SP1
; Description ...: Get the weekday on any given date
; Modified ......: 2014.04.15-0925
; Author ........: jNizM
; Licence .......: WTFPL (http://www.wtfpl.net/txt/copying/)
; Source ........: https://github.com/jNizM/AutoHotkey_Scripts/blob/master/Functions/Others/GetWeekday.ahk
;Modified .......: 2018.04.01. by Ixiko - two languages two formats, you have to only use your date English format 01-03-1990
; or german format 03.01.1990 - you can use default Delimiter or choose your own
; ===================================================================================
; GLOBAL SETTINGS ===================================================================
#NoEnv
#SingleInstance Force
; SCRIPT ============================================================================
MsgBox, % GetWeekday("1-1-1990", "en", "", "en") ; --> Monday
MsgBox, % GetWeekday("15.4.2014", "ge", "","de") ; --> Dienstag
MsgBox, % GetWeekday("15.4.2014", "ge", "","en") ; --> ThuesDay
ExitApp
; FUNCTIONS =========================================================================
GetWeekday(date, format, DelimitChar:="", outlang:="en" ) {
WeekDay:= Object()
WeekDay.En:= Object(Weekday)
WeekDay.Ge= Object(Weekday)
WeekDay.En:= ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
WeekDay.Ge:= ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Sonnabend"]
;append or change the following for your language
If (format="en") {
If (DelimitChar="") {
DelimitChar:= "-"
}
StringSplit, split, date, %DelimitChar%
d:= split2, m:= split1, y:= split3
} else if (format="ge") {
If (DelimitChar="") {
DelimitChar:= "`."
}
StringSplit, split, date, %DelimitChar%
d:= split1, m:= split2, y:= split3
}
if (m < 3) {
m += 12
y -= 1
}
wd:= mod(d + (2 * m) + floor(6 * (m + 1) / 10) + y + floor(y / 4) - floor(y / 100) + floor(y / 400) + 1, 7) + 1
ListVars
MsgBox, %wd%
return WeekDay%outlang%[wd]
}