@whitewizard/countdown 1.0.5 → 1.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.
Files changed (2) hide show
  1. package/countdown.vue +12 -3
  2. package/package.json +1 -2
package/countdown.vue CHANGED
@@ -9,7 +9,6 @@
9
9
  </template>
10
10
 
11
11
  <script>
12
- import leftPad from 'left-pad';
13
12
  import moment from 'moment';
14
13
 
15
14
  export default {
@@ -58,7 +57,7 @@
58
57
 
59
58
  if (!diffArray.length) {
60
59
  // first unit value needs to include all the time that isn't included in smaller units
61
- // get whole duration as largest unit and round down
60
+ // get whole duration as largest unit and round down.
62
61
  partDuration = Math.floor(wholeDuration.as(part));
63
62
  } else {
64
63
  partDuration = Math.floor(wholeDuration.get(part));
@@ -73,11 +72,21 @@
73
72
  },
74
73
  methods: {
75
74
  getDatePart(i) {
76
- return leftPad(this.getDiffArray[i] || 0, 2, 0);
75
+ return this.getDiffArray[i].padStart(2, '0');
77
76
  },
78
77
  getSeparator(i) {
79
78
  if (typeof this.separators !== 'string' && this.separators.length === 2) {
80
79
  return this.separators[this.getDatePart(i) === '01' ? 1 : 0].split(':')[i];
80
+ } else if (typeof this.separators !== 'string' && this.separators.length === 3) { //for Russian
81
+ let separatorIndex = 0;
82
+ const timeDigit = Number(this.getDatePart(i))
83
+ if (timeDigit % 10 === 1 && timeDigit !== 11) {
84
+ separatorIndex = 1;
85
+ } else if ([2, 3, 4].includes(timeDigit % 10) && !([12, 13, 14].includes(timeDigit))) {
86
+ separatorIndex = 2;
87
+ }
88
+
89
+ return this.separators[separatorIndex].split(':')[i];
81
90
  }
82
91
 
83
92
  return this.getSeparators[i];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whitewizard/countdown",
3
- "version": "1.0.5",
3
+ "version": "1.1.0",
4
4
  "description": "Universal countdown Vue component",
5
5
  "main": "countdown.vue",
6
6
  "scripts": {
@@ -10,7 +10,6 @@
10
10
  "author": "Mikk Narusk",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "left-pad": "^1.1.3",
14
13
  "moment": "^2.19.1"
15
14
  },
16
15
  "devDependencies": {