react-native-nepali-picker 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +31 -0
- package/lib/commonjs/CalendarPicker.js +368 -0
- package/lib/commonjs/CalendarPicker.js.map +1 -0
- package/lib/commonjs/assets/DateSync.js +105 -0
- package/lib/commonjs/assets/DateSync.js.map +1 -0
- package/lib/commonjs/assets/Icons.js +182 -0
- package/lib/commonjs/assets/Icons.js.map +1 -0
- package/lib/commonjs/assets/Triangle.js +37 -0
- package/lib/commonjs/assets/Triangle.js.map +1 -0
- package/lib/commonjs/assets/cIcon.js +76 -0
- package/lib/commonjs/assets/cIcon.js.map +1 -0
- package/lib/commonjs/calendar/config.js +125 -0
- package/lib/commonjs/calendar/config.js.map +1 -0
- package/lib/commonjs/calendar/functions.js +114 -0
- package/lib/commonjs/calendar/functions.js.map +1 -0
- package/lib/commonjs/calendar/settings.js +40 -0
- package/lib/commonjs/calendar/settings.js.map +1 -0
- package/lib/commonjs/index.js +33 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/CalendarPicker.js +363 -0
- package/lib/module/CalendarPicker.js.map +1 -0
- package/lib/module/assets/DateSync.js +101 -0
- package/lib/module/assets/DateSync.js.map +1 -0
- package/lib/module/assets/Icons.js +175 -0
- package/lib/module/assets/Icons.js.map +1 -0
- package/lib/module/assets/Triangle.js +33 -0
- package/lib/module/assets/Triangle.js.map +1 -0
- package/lib/module/assets/cIcon.js +72 -0
- package/lib/module/assets/cIcon.js.map +1 -0
- package/lib/module/calendar/config.js +121 -0
- package/lib/module/calendar/config.js.map +1 -0
- package/lib/module/calendar/functions.js +106 -0
- package/lib/module/calendar/functions.js.map +1 -0
- package/lib/module/calendar/settings.js +35 -0
- package/lib/module/calendar/settings.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/CalendarPicker.d.ts +13 -0
- package/lib/typescript/commonjs/src/CalendarPicker.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/assets/DateSync.d.ts +7 -0
- package/lib/typescript/commonjs/src/assets/DateSync.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/assets/Icons.d.ts +20 -0
- package/lib/typescript/commonjs/src/assets/Icons.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/assets/Triangle.d.ts +7 -0
- package/lib/typescript/commonjs/src/assets/Triangle.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/assets/cIcon.d.ts +6 -0
- package/lib/typescript/commonjs/src/assets/cIcon.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/calendar/config.d.ts +9 -0
- package/lib/typescript/commonjs/src/calendar/config.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/calendar/functions.d.ts +7 -0
- package/lib/typescript/commonjs/src/calendar/functions.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/calendar/settings.d.ts +4 -0
- package/lib/typescript/commonjs/src/calendar/settings.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +4 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/CalendarPicker.d.ts +13 -0
- package/lib/typescript/module/src/CalendarPicker.d.ts.map +1 -0
- package/lib/typescript/module/src/assets/DateSync.d.ts +7 -0
- package/lib/typescript/module/src/assets/DateSync.d.ts.map +1 -0
- package/lib/typescript/module/src/assets/Icons.d.ts +20 -0
- package/lib/typescript/module/src/assets/Icons.d.ts.map +1 -0
- package/lib/typescript/module/src/assets/Triangle.d.ts +7 -0
- package/lib/typescript/module/src/assets/Triangle.d.ts.map +1 -0
- package/lib/typescript/module/src/assets/cIcon.d.ts +6 -0
- package/lib/typescript/module/src/assets/cIcon.d.ts.map +1 -0
- package/lib/typescript/module/src/calendar/config.d.ts +9 -0
- package/lib/typescript/module/src/calendar/config.d.ts.map +1 -0
- package/lib/typescript/module/src/calendar/functions.d.ts +7 -0
- package/lib/typescript/module/src/calendar/functions.d.ts.map +1 -0
- package/lib/typescript/module/src/calendar/settings.d.ts +4 -0
- package/lib/typescript/module/src/calendar/settings.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +4 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/package.json +949 -0
- package/src/CalendarPicker.tsx +460 -0
- package/src/assets/DateSync.tsx +84 -0
- package/src/assets/Icons.tsx +143 -0
- package/src/assets/Triangle.tsx +31 -0
- package/src/assets/cIcon.tsx +74 -0
- package/src/calendar/config.ts +263 -0
- package/src/calendar/functions.ts +126 -0
- package/src/calendar/settings.ts +45 -0
- package/src/index.tsx +4 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { View, StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
const Triangle = ({ width = 10, height = 20, color = 'black' }) => {
|
|
4
|
+
return (
|
|
5
|
+
<View
|
|
6
|
+
style={[
|
|
7
|
+
styles.triangle,
|
|
8
|
+
{
|
|
9
|
+
borderLeftWidth: width / 2,
|
|
10
|
+
borderRightWidth: width / 2,
|
|
11
|
+
borderBottomWidth: height,
|
|
12
|
+
borderBottomColor: color,
|
|
13
|
+
},
|
|
14
|
+
]}
|
|
15
|
+
/>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const styles = StyleSheet.create({
|
|
20
|
+
triangle: {
|
|
21
|
+
width: 0,
|
|
22
|
+
height: 0,
|
|
23
|
+
transform: [{ rotate: '180deg' }],
|
|
24
|
+
backgroundColor: 'transparent',
|
|
25
|
+
borderStyle: 'solid',
|
|
26
|
+
borderLeftColor: 'transparent',
|
|
27
|
+
borderRightColor: 'transparent',
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export default Triangle;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { View, StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
const PencilIcon = ({ height = 20, width = 10 }) => {
|
|
4
|
+
return (
|
|
5
|
+
<View style={{ ...styles.container, height: height, width: width }}>
|
|
6
|
+
{/* Eraser */}
|
|
7
|
+
<View
|
|
8
|
+
style={{
|
|
9
|
+
height: '40%',
|
|
10
|
+
width: '100%',
|
|
11
|
+
borderTopStartRadius: 3,
|
|
12
|
+
borderTopEndRadius: 3,
|
|
13
|
+
borderWidth: 0.7,
|
|
14
|
+
}}
|
|
15
|
+
>
|
|
16
|
+
<View
|
|
17
|
+
style={{
|
|
18
|
+
top: '50%',
|
|
19
|
+
width: '100%',
|
|
20
|
+
borderWidth: 0.7,
|
|
21
|
+
}}
|
|
22
|
+
/>
|
|
23
|
+
</View>
|
|
24
|
+
|
|
25
|
+
{/* Body */}
|
|
26
|
+
<View
|
|
27
|
+
style={{
|
|
28
|
+
height: '90%',
|
|
29
|
+
width: '100%',
|
|
30
|
+
borderWidth: 0.7,
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
<View
|
|
34
|
+
style={{
|
|
35
|
+
left: '50%',
|
|
36
|
+
height: '100%',
|
|
37
|
+
width: 0,
|
|
38
|
+
borderWidth: 0.2,
|
|
39
|
+
}}
|
|
40
|
+
/>
|
|
41
|
+
</View>
|
|
42
|
+
{/* tip of pencil */}
|
|
43
|
+
{/* <View style={{ height: '30%', width: '100%', backgroundColor: '#000' }}>
|
|
44
|
+
<View />
|
|
45
|
+
</View> */}
|
|
46
|
+
<View
|
|
47
|
+
style={{
|
|
48
|
+
width: 0,
|
|
49
|
+
height: 0,
|
|
50
|
+
borderLeftWidth: 4,
|
|
51
|
+
borderRightWidth: 4,
|
|
52
|
+
borderBottomWidth: 0,
|
|
53
|
+
borderStyle: 'solid',
|
|
54
|
+
backgroundColor: 'transparent',
|
|
55
|
+
borderLeftColor: 'transparent',
|
|
56
|
+
borderRightColor: 'transparent',
|
|
57
|
+
borderBottomColor: 'transparent',
|
|
58
|
+
borderTopWidth: 8,
|
|
59
|
+
}}
|
|
60
|
+
/>
|
|
61
|
+
</View>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const styles = StyleSheet.create({
|
|
66
|
+
container: {
|
|
67
|
+
transform: [{ rotate: '45deg' }],
|
|
68
|
+
alignItems: 'center',
|
|
69
|
+
marginHorizontal: 'auto',
|
|
70
|
+
justifyContent: 'center',
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export default PencilIcon;
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
const bs: number[][] = [];
|
|
2
|
+
bs[2000] = [2000, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
3
|
+
|
|
4
|
+
bs[2001] = [2001, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
5
|
+
|
|
6
|
+
bs[2002] = [2002, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
7
|
+
|
|
8
|
+
bs[2003] = [2003, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
9
|
+
|
|
10
|
+
bs[2004] = [2004, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
11
|
+
|
|
12
|
+
bs[2005] = [2005, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
13
|
+
|
|
14
|
+
bs[2006] = [2006, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
15
|
+
|
|
16
|
+
bs[2007] = [2007, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
17
|
+
|
|
18
|
+
bs[2008] = [2008, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31];
|
|
19
|
+
|
|
20
|
+
bs[2009] = [2009, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
21
|
+
|
|
22
|
+
bs[2010] = [2010, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
23
|
+
|
|
24
|
+
bs[2011] = [2011, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
25
|
+
|
|
26
|
+
bs[2012] = [2012, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30];
|
|
27
|
+
|
|
28
|
+
bs[2013] = [2013, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
29
|
+
|
|
30
|
+
bs[2014] = [2014, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
31
|
+
|
|
32
|
+
bs[2015] = [2015, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
33
|
+
|
|
34
|
+
bs[2016] = [2016, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30];
|
|
35
|
+
|
|
36
|
+
bs[2017] = [2017, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
37
|
+
|
|
38
|
+
bs[2018] = [2018, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
39
|
+
|
|
40
|
+
bs[2019] = [2019, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
41
|
+
|
|
42
|
+
bs[2020] = [2020, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
43
|
+
|
|
44
|
+
bs[2021] = [2021, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
45
|
+
|
|
46
|
+
bs[2022] = [2022, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30];
|
|
47
|
+
|
|
48
|
+
bs[2023] = [2023, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
49
|
+
|
|
50
|
+
bs[2024] = [2024, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
51
|
+
|
|
52
|
+
bs[2025] = [2025, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
53
|
+
|
|
54
|
+
bs[2026] = [2026, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
55
|
+
|
|
56
|
+
bs[2027] = [2027, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
57
|
+
|
|
58
|
+
bs[2028] = [2028, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
59
|
+
|
|
60
|
+
bs[2029] = [2029, 31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30];
|
|
61
|
+
|
|
62
|
+
bs[2030] = [2030, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
63
|
+
|
|
64
|
+
bs[2031] = [2031, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
65
|
+
|
|
66
|
+
bs[2032] = [2032, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
67
|
+
|
|
68
|
+
bs[2033] = [2033, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
69
|
+
|
|
70
|
+
bs[2034] = [2034, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
71
|
+
|
|
72
|
+
bs[2035] = [2035, 30, 32, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31];
|
|
73
|
+
|
|
74
|
+
bs[2036] = [2036, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
75
|
+
|
|
76
|
+
bs[2037] = [2037, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
77
|
+
|
|
78
|
+
bs[2038] = [2038, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
79
|
+
|
|
80
|
+
bs[2039] = [2039, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30];
|
|
81
|
+
|
|
82
|
+
bs[2040] = [2040, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
83
|
+
|
|
84
|
+
bs[2041] = [2041, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
85
|
+
|
|
86
|
+
bs[2042] = [2042, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
87
|
+
|
|
88
|
+
bs[2043] = [2043, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30];
|
|
89
|
+
|
|
90
|
+
bs[2044] = [2044, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
91
|
+
|
|
92
|
+
bs[2045] = [2045, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
93
|
+
|
|
94
|
+
bs[2046] = [2046, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
95
|
+
|
|
96
|
+
bs[2047] = [2047, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
97
|
+
|
|
98
|
+
bs[2048] = [2048, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
99
|
+
|
|
100
|
+
bs[2049] = [2049, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30];
|
|
101
|
+
|
|
102
|
+
bs[2050] = [2050, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
103
|
+
|
|
104
|
+
bs[2051] = [2051, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
105
|
+
|
|
106
|
+
bs[2052] = [2052, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
107
|
+
|
|
108
|
+
bs[2053] = [2053, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30];
|
|
109
|
+
|
|
110
|
+
bs[2054] = [2054, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
111
|
+
|
|
112
|
+
bs[2055] = [2055, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
113
|
+
|
|
114
|
+
bs[2056] = [2056, 31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30];
|
|
115
|
+
|
|
116
|
+
bs[2057] = [2057, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
117
|
+
|
|
118
|
+
bs[2058] = [2058, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
119
|
+
|
|
120
|
+
bs[2059] = [2059, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
121
|
+
|
|
122
|
+
bs[2060] = [2060, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
123
|
+
|
|
124
|
+
bs[2061] = [2061, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
125
|
+
|
|
126
|
+
bs[2062] = [2062, 30, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31];
|
|
127
|
+
|
|
128
|
+
bs[2063] = [2063, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
129
|
+
|
|
130
|
+
bs[2064] = [2064, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
131
|
+
|
|
132
|
+
bs[2065] = [2065, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
133
|
+
|
|
134
|
+
bs[2066] = [2066, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31];
|
|
135
|
+
|
|
136
|
+
bs[2067] = [2067, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
137
|
+
|
|
138
|
+
bs[2068] = [2068, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
139
|
+
|
|
140
|
+
bs[2069] = [2069, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
141
|
+
|
|
142
|
+
bs[2070] = [2070, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30];
|
|
143
|
+
|
|
144
|
+
bs[2071] = [2071, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
145
|
+
|
|
146
|
+
bs[2072] = [2072, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
147
|
+
|
|
148
|
+
bs[2073] = [2073, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
149
|
+
|
|
150
|
+
bs[2074] = [2074, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
151
|
+
|
|
152
|
+
bs[2075] = [2075, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
153
|
+
|
|
154
|
+
bs[2076] = [2076, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30];
|
|
155
|
+
|
|
156
|
+
bs[2077] = [2077, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
157
|
+
|
|
158
|
+
bs[2078] = [2078, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
159
|
+
|
|
160
|
+
bs[2079] = [2079, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
161
|
+
|
|
162
|
+
bs[2080] = [2080, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30];
|
|
163
|
+
|
|
164
|
+
bs[2081] = [2081, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
165
|
+
|
|
166
|
+
bs[2082] = [2082, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
167
|
+
|
|
168
|
+
bs[2083] = [2083, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
169
|
+
|
|
170
|
+
bs[2084] = [2084, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
171
|
+
|
|
172
|
+
bs[2085] = [2085, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
173
|
+
|
|
174
|
+
bs[2086] = [2086, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
175
|
+
|
|
176
|
+
bs[2087] = [2087, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
177
|
+
|
|
178
|
+
bs[2088] = [2088, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
179
|
+
|
|
180
|
+
bs[2089] = [2089, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31];
|
|
181
|
+
|
|
182
|
+
bs[2090] = [2090, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
183
|
+
|
|
184
|
+
bs[2091] = [2091, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
185
|
+
|
|
186
|
+
bs[2092] = [2092, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
187
|
+
|
|
188
|
+
bs[2093] = [2093, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31];
|
|
189
|
+
|
|
190
|
+
bs[2094] = [2094, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
191
|
+
|
|
192
|
+
bs[2095] = [2095, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
193
|
+
|
|
194
|
+
bs[2096] = [2096, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31];
|
|
195
|
+
|
|
196
|
+
bs[2097] = [2097, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30];
|
|
197
|
+
|
|
198
|
+
bs[2098] = [2098, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30];
|
|
199
|
+
|
|
200
|
+
bs[2099] = [2099, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30];
|
|
201
|
+
|
|
202
|
+
const leapYears: number[] = [];
|
|
203
|
+
for (let i = 2000; i < 2100; i++) {
|
|
204
|
+
let totalD = 0;
|
|
205
|
+
for (let j = 1; j <= 12; j++) {
|
|
206
|
+
totalD += bs[i][j];
|
|
207
|
+
}
|
|
208
|
+
if (totalD === 366) leapYears.push(i);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const daysInEnglish = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
212
|
+
|
|
213
|
+
const daysInNepali = ['आइत', 'सोम', 'मंगल', 'बुध', 'बिहि', 'शुक्र', 'शनि'];
|
|
214
|
+
|
|
215
|
+
const monthsInEnglish = [
|
|
216
|
+
'Baishakh',
|
|
217
|
+
'Jestha',
|
|
218
|
+
'Ashadh',
|
|
219
|
+
'Shrawan',
|
|
220
|
+
'Bhadra',
|
|
221
|
+
'Ashoj',
|
|
222
|
+
'Kartik',
|
|
223
|
+
'Mangsir',
|
|
224
|
+
'Poush',
|
|
225
|
+
'Magh',
|
|
226
|
+
'Falgun',
|
|
227
|
+
'Chaitra',
|
|
228
|
+
];
|
|
229
|
+
|
|
230
|
+
const monthsInNepali = [
|
|
231
|
+
'बैशाख',
|
|
232
|
+
'जेठ',
|
|
233
|
+
'असार',
|
|
234
|
+
'श्रावण',
|
|
235
|
+
'भदौ',
|
|
236
|
+
'असोज',
|
|
237
|
+
'कार्तिक',
|
|
238
|
+
'मंसिर',
|
|
239
|
+
'पुष',
|
|
240
|
+
'माघ',
|
|
241
|
+
'फाल्गुन',
|
|
242
|
+
'चैत्र',
|
|
243
|
+
];
|
|
244
|
+
|
|
245
|
+
const nepaliNumber = ['०', '१', '२', '३', '४', '५', '६', '७', '८', '९'];
|
|
246
|
+
|
|
247
|
+
const getNepaliNumber = (engNum: number) => {
|
|
248
|
+
return engNum
|
|
249
|
+
.toString()
|
|
250
|
+
.split('')
|
|
251
|
+
.map((n: any) => nepaliNumber[n])
|
|
252
|
+
.join('');
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
export {
|
|
256
|
+
bs,
|
|
257
|
+
daysInNepali,
|
|
258
|
+
daysInEnglish,
|
|
259
|
+
monthsInNepali,
|
|
260
|
+
monthsInEnglish,
|
|
261
|
+
getNepaliNumber,
|
|
262
|
+
leapYears,
|
|
263
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { bs } from './config';
|
|
2
|
+
|
|
3
|
+
const formatDate = (date: Date) => {
|
|
4
|
+
const year = date.getFullYear();
|
|
5
|
+
const month = String(date.getMonth() + 1).padStart(2, '0'); // Months are zero-based
|
|
6
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
7
|
+
return `${year}-${month}-${day}`;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const FindDateDifference = (date1: number, date2: number) => {
|
|
11
|
+
const diffInMs = date2 - date1;
|
|
12
|
+
const diffInDays = diffInMs / (1000 * 60 * 60 * 24);
|
|
13
|
+
return diffInDays;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const AdToBs = (UserDate: string): string => {
|
|
17
|
+
const ReferenceDate = new Date('1943-04-14').getTime();
|
|
18
|
+
const UserTimeDate = new Date(UserDate).getTime();
|
|
19
|
+
|
|
20
|
+
if (UserTimeDate < ReferenceDate) {
|
|
21
|
+
console.log(
|
|
22
|
+
'The minimum possible date you can enter is 2024-04-13 i.e 2081-01-01'
|
|
23
|
+
);
|
|
24
|
+
return 'The minimum possible date you can enter is 2024-04-13 i.e 2081-01-01';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// number of days from that reference date
|
|
28
|
+
const DateDifference = FindDateDifference(ReferenceDate, UserTimeDate);
|
|
29
|
+
let nepaliYear: number = 2000;
|
|
30
|
+
let nepaliMonth: number = 1;
|
|
31
|
+
let nepaliDay: number = 1;
|
|
32
|
+
let DD = DateDifference;
|
|
33
|
+
|
|
34
|
+
outerLoop: for (let year = 2000; year < 2100; year++) {
|
|
35
|
+
for (let month = 1; month <= 12; month++) {
|
|
36
|
+
if (DD <= bs[year][month]) {
|
|
37
|
+
//difference can calculate upto previous day so add 1 to get current day(Today)
|
|
38
|
+
nepaliYear = year;
|
|
39
|
+
nepaliMonth = month;
|
|
40
|
+
nepaliDay = DD + 1;
|
|
41
|
+
break outerLoop;
|
|
42
|
+
} else {
|
|
43
|
+
DD -= bs[year][month];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return `${nepaliYear}-${String(nepaliMonth).padStart(2, '0')}-${String(
|
|
49
|
+
nepaliDay
|
|
50
|
+
).padStart(2, '0')}`;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const NepaliToday = (): string => {
|
|
54
|
+
const ReferenceDate = new Date('1943-04-14').getTime();
|
|
55
|
+
const TodayDate = Date.now();
|
|
56
|
+
const date = new Date(TodayDate);
|
|
57
|
+
// number of return from that reference date
|
|
58
|
+
const DateDifference = FindDateDifference(
|
|
59
|
+
ReferenceDate,
|
|
60
|
+
new Date(formatDate(date)).getTime()
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
let nepaliYear: number = 2000;
|
|
64
|
+
let nepaliMonth: number = 1;
|
|
65
|
+
let nepaliDay: number = 1;
|
|
66
|
+
//difference can calculate upto previous day so add 1 to get current day(Today)
|
|
67
|
+
let DD = DateDifference + 1;
|
|
68
|
+
outerLoop: for (let year = 2000; year < 2100; year++) {
|
|
69
|
+
for (let month = 1; month <= 12; month++) {
|
|
70
|
+
if (DD <= bs[year][month]) {
|
|
71
|
+
nepaliYear = year;
|
|
72
|
+
nepaliMonth = month;
|
|
73
|
+
nepaliDay = DD;
|
|
74
|
+
break outerLoop;
|
|
75
|
+
} else {
|
|
76
|
+
DD -= bs[year][month];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return `${nepaliYear}-${String(nepaliMonth).padStart(2, '0')}-${String(
|
|
81
|
+
nepaliDay
|
|
82
|
+
).padStart(2, '0')}`;
|
|
83
|
+
// return DateDifference;
|
|
84
|
+
//add the difference between reference and today date to nepali reference date and find new today nepali date
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const BsToAd = (userDate: string): string => {
|
|
88
|
+
try {
|
|
89
|
+
const dateArray = userDate.split('-');
|
|
90
|
+
let dateDifference = 0;
|
|
91
|
+
if (dateArray.length !== 3) {
|
|
92
|
+
throw new Error('Invalid date format');
|
|
93
|
+
}
|
|
94
|
+
const [userYear, userMonth, userDay] = dateArray.map(Number);
|
|
95
|
+
if (userYear < 2000 || userYear >= 2100) {
|
|
96
|
+
throw new Error('Year Range is 2000 to 2099');
|
|
97
|
+
}
|
|
98
|
+
if (userMonth < 1 || userMonth > 12) {
|
|
99
|
+
throw new Error('Month Range is 1 to 12');
|
|
100
|
+
}
|
|
101
|
+
// if (userMonth < 1 || userMonth > 31) {
|
|
102
|
+
// throw new Error('Month out of supported range');
|
|
103
|
+
// }
|
|
104
|
+
for (let year = 2000; year < userYear; year++) {
|
|
105
|
+
for (let month = 1; month <= 12; month++) {
|
|
106
|
+
dateDifference += bs[year][month];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
for (let month = 1; month < userMonth; month++) {
|
|
111
|
+
dateDifference += bs[userYear][month];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
dateDifference += userDay - 1;
|
|
115
|
+
|
|
116
|
+
const referenceDate = new Date('1943-04-14');
|
|
117
|
+
const futureDate = new Date(referenceDate);
|
|
118
|
+
futureDate.setDate(referenceDate.getDate() + dateDifference);
|
|
119
|
+
|
|
120
|
+
return futureDate.toISOString().split('T')[0];
|
|
121
|
+
} catch (error) {
|
|
122
|
+
return ' Year Range is 2000 to 2099';
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export { AdToBs, BsToAd, formatDate, FindDateDifference, NepaliToday };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { bs, leapYears } from './config';
|
|
2
|
+
|
|
3
|
+
const calcFirstDay = (currentYear: number, currentMonth: number) => {
|
|
4
|
+
let month = currentMonth;
|
|
5
|
+
let year = currentYear;
|
|
6
|
+
const diff = year - 2000;
|
|
7
|
+
let leapYear = 0;
|
|
8
|
+
let firstDay;
|
|
9
|
+
for (let l = 0; l < leapYears.length; l++) {
|
|
10
|
+
if (year > leapYears[l]) {
|
|
11
|
+
leapYear++;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
// if (year > 2096) {
|
|
15
|
+
// leapYear--;
|
|
16
|
+
// }
|
|
17
|
+
//calculate number of days since the first refernce year i.e 2081
|
|
18
|
+
let td = 3 + diff * 365 + leapYear;
|
|
19
|
+
if (month - 1 > 0) {
|
|
20
|
+
for (let i = 1; i < month; i++) {
|
|
21
|
+
td += bs[year][i];
|
|
22
|
+
}
|
|
23
|
+
firstDay = td % 7;
|
|
24
|
+
} else {
|
|
25
|
+
firstDay = td % 7;
|
|
26
|
+
}
|
|
27
|
+
td = 0;
|
|
28
|
+
return firstDay;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const isToday = (
|
|
32
|
+
date: string,
|
|
33
|
+
index: number,
|
|
34
|
+
currentYear: number,
|
|
35
|
+
currentMonth: number,
|
|
36
|
+
firstDayOfMonth: number
|
|
37
|
+
) => {
|
|
38
|
+
return (
|
|
39
|
+
parseInt(date.slice(-2)) - 1 + firstDayOfMonth === index &&
|
|
40
|
+
currentMonth === parseInt(date.slice(6, 8)) &&
|
|
41
|
+
currentYear === parseInt(date.slice(0, 4))
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export { calcFirstDay, isToday };
|
package/src/index.tsx
ADDED