-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples.py
More file actions
136 lines (114 loc) · 4.13 KB
/
examples.py
File metadata and controls
136 lines (114 loc) · 4.13 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import shared_function as sf
from inifiles import IniFiles
# Write and read ini file
ini = IniFiles(config_file="sett.ini")
ini.write_option("section", "option", "value")
print(ini.read_option("section", "option"))
# Return position of substring
print(str(sf.get_char_index(string="/home/my/path", char="y")))
# Create folder if it not already exists
# Get value of $HOME, append "/aaa/bbb" and create this folder
print(sf.create_folder(folder_path="$HOME/aaa/bbb"))
# Create folder with value of $HOME
print(sf.create_folder(folder_path="$HOME"))
# Create folder with path "/home/user/q/w/e"
print(sf.create_folder(folder_path="/home/user/q/w/e"))
# If folder path start without / or $ folder will create in script folder
print(sf.create_folder(folder_path="zzz/xxx"))
# Simple function for get system environment
print(sf.decode_system_env(sys_env="$HOME"))
# Return script folder
print(sf.get_script_folder())
# To get current date in short you should call
print("function - get_current_date")
data = sf.get_current_date()
print(type(data))
print(data)
# To get current date time you should call
print("function - get_current_date_time")
data = sf.get_current_date_time()
print(type(data))
print(data)
# To get current date/time in custom format, you should call
# Current date without year and day of week
print("function - get_current_date_time_custom_format")
date_time_format = "%m %d, %A"
data = sf.get_current_date_time_custom_format(date_time_custom_format=date_time_format)
print(type(data))
print(data)
# To get tomorrow or yesterday you should call
print("function - get_tomorrow")
data = sf.get_tomorrow()
print(data)
print(type(data))
print("function - get_yesterday")
data = sf.get_yesterday()
print(type(data))
print(data)
# To get next date after several days (+2 days)
print("function - get_date_period +2 days")
cur_date = sf.get_current_date()
data = sf.get_date_period(current_date=cur_date, period=2)
print(type(data))
print(str(cur_date) + " +2 days = " + str(data))
# To get previous date before several days (-3 days) in custom format (month, day)
print("function - get_date_period - 3 days")
cur_date = sf.get_current_date()
data = sf.get_date_period(current_date=cur_date, period=-3)
print(type(data))
print(str(cur_date) + " -3 days = " + str(data))
# To get next month
print("function - get_month_next")
data = sf.get_month_next(sf.get_current_date())
print(type(data))
print(data)
# To get previous month
print("function - get_month_previous")
data = sf.get_month_previous(sf.get_current_date())
print(type(data))
print(data)
# To get next month after current date (+3 months)
print("function - get_month_period +3 month")
data = sf.get_month_period(sf.get_current_date(), period=3)
print(type(data))
print(data)
# To get previous month before current date (-6 months)
print("function - get_month_period -6 month")
data = sf.get_month_period(sf.get_current_date(), period=-6)
print(type(data))
print(data)
# Get number of days in month
print("function - get_days_number")
data = sf.get_days_number(sf.get_current_date())
print(type(data))
print(data)
# If you want get first day of current month you can call
print("function - get_first_day_of_month")
data = sf.get_first_day_of_month(sf.get_current_date())
print(type(data))
print(data)
# For get first day of next month you can call
print("function - get_first_day_of_next_month")
data = sf.get_first_day_of_next_month(sf.get_current_date())
print(type(data))
print(data)
# For get first day of previous month you can call
print("function - get_first_day_of_previous_month")
data = sf.get_first_day_of_previous_month(sf.get_current_date())
print(type(data))
print(data)
# Get last day of month
print("function - get_last_day_of_month")
data = sf.get_last_day_of_month(sf.get_current_date())
print(type(data))
print(data)
# Get last day of next month
print("function - get_last_day_of_next_month")
data = sf.get_last_day_of_next_month(sf.get_current_date())
print(type(data))
print(data)
# Get last day of previous month
print("function - get_last_day_of_previous_month")
data = sf.get_last_day_of_previous_month(sf.get_current_date())
print(type(data))
print(data)