@osovitny/anatoly 2.0.42 → 2.0.44
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/bundles/osovitny-anatoly.umd.js +50 -25
- package/bundles/osovitny-anatoly.umd.js.map +1 -1
- package/bundles/osovitny-anatoly.umd.min.js +2 -2
- package/bundles/osovitny-anatoly.umd.min.js.map +1 -1
- package/esm2015/lib/core/localization/localization.service.js +34 -16
- package/esm2015/lib/core/localization/localize.pipe.js +20 -13
- package/fesm2015/osovitny-anatoly.js +51 -26
- package/fesm2015/osovitny-anatoly.js.map +1 -1
- package/lib/core/localization/localization.service.d.ts +3 -2
- package/osovitny-anatoly.metadata.json +1 -1
- package/package.json +1 -1
|
@@ -722,7 +722,6 @@
|
|
|
722
722
|
return "Invalid Date";
|
|
723
723
|
};
|
|
724
724
|
LocalizationService.prototype.getLocalizedDateTime = function (key) {
|
|
725
|
-
//To Do Manoj: Test in IE and make TimeZone specific changes accordingly
|
|
726
725
|
var dateValue = new Date(key);
|
|
727
726
|
if (dateFns.isValid(dateValue)) {
|
|
728
727
|
var localDate = Convert.toLocalizedDateTime(dateValue);
|
|
@@ -730,6 +729,37 @@
|
|
|
730
729
|
}
|
|
731
730
|
return "Invalid Date";
|
|
732
731
|
};
|
|
732
|
+
LocalizationService.prototype.getLocalizedDistanceInWords = function (endedDate, startedDate) {
|
|
733
|
+
if (dateFns.isValid(new Date(endedDate)) && dateFns.isValid(new Date(startedDate))) {
|
|
734
|
+
return dateFns.formatDistance(new Date(endedDate), new Date(startedDate), this.dateFnsLocale);
|
|
735
|
+
}
|
|
736
|
+
return "Invalid Date";
|
|
737
|
+
};
|
|
738
|
+
LocalizationService.prototype.getLocalizedDistanceToNowInWords = function (date) {
|
|
739
|
+
if (dateFns.isValid(new Date(date))) {
|
|
740
|
+
return dateFns.formatDistanceToNow(new Date(date), this.dateFnsLocale);
|
|
741
|
+
}
|
|
742
|
+
return "Invalid Date";
|
|
743
|
+
};
|
|
744
|
+
//UTC Operations --------------------------------------------------------------
|
|
745
|
+
LocalizationService.prototype.getUTCToLocalizedDate = function (key) {
|
|
746
|
+
var browserTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
747
|
+
if (key) {
|
|
748
|
+
if (key.indexOf("T") == -1) {
|
|
749
|
+
key = key.replace(" ", "T");
|
|
750
|
+
}
|
|
751
|
+
if (key.indexOf("Z") == -1) {
|
|
752
|
+
key = key + "Z";
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
if (browserTimeZone) {
|
|
756
|
+
var localDateTime = dateFnsTz.utcToZonedTime(key, browserTimeZone);
|
|
757
|
+
return dateFns.format(localDateTime, 'dd.MM.yyyy', this.dateFnsLocale);
|
|
758
|
+
}
|
|
759
|
+
else {
|
|
760
|
+
return dateFns.format(new Date(key), 'dd.MM.yyyy', this.dateFnsLocale);
|
|
761
|
+
}
|
|
762
|
+
};
|
|
733
763
|
LocalizationService.prototype.getUTCToLocalizedDateTime = function (key) {
|
|
734
764
|
var browserTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
735
765
|
if (key) {
|
|
@@ -742,10 +772,10 @@
|
|
|
742
772
|
}
|
|
743
773
|
if (browserTimeZone) {
|
|
744
774
|
var localDateTime = dateFnsTz.utcToZonedTime(key, browserTimeZone);
|
|
745
|
-
return dateFns.format(localDateTime, '
|
|
775
|
+
return dateFns.format(localDateTime, 'dd.MM.yyyy HH:mm', this.dateFnsLocale);
|
|
746
776
|
}
|
|
747
777
|
else {
|
|
748
|
-
return dateFns.format(new Date(key), '
|
|
778
|
+
return dateFns.format(new Date(key), 'dd.MM.yyyy HH:mm', this.dateFnsLocale);
|
|
749
779
|
}
|
|
750
780
|
};
|
|
751
781
|
//https://date-fns.org/v1.30.1/docs/distanceInWords
|
|
@@ -756,18 +786,6 @@
|
|
|
756
786
|
}
|
|
757
787
|
return "Invalid Date";
|
|
758
788
|
};
|
|
759
|
-
LocalizationService.prototype.getLocalizedDistanceToNowInWords = function (date) {
|
|
760
|
-
if (dateFns.isValid(new Date(date))) {
|
|
761
|
-
return dateFns.formatDistanceToNow(new Date(date), this.dateFnsLocale);
|
|
762
|
-
}
|
|
763
|
-
return "Invalid Date";
|
|
764
|
-
};
|
|
765
|
-
LocalizationService.prototype.getLocalizedDistanceInWords = function (endedDate, startedDate) {
|
|
766
|
-
if (dateFns.isValid(new Date(endedDate)) && dateFns.isValid(new Date(startedDate))) {
|
|
767
|
-
return dateFns.formatDistance(new Date(endedDate), new Date(startedDate), this.dateFnsLocale);
|
|
768
|
-
}
|
|
769
|
-
return "Invalid Date";
|
|
770
|
-
};
|
|
771
789
|
LocalizationService.prototype.safeUtcToZonedTime = function (date) {
|
|
772
790
|
var result = date;
|
|
773
791
|
try {
|
|
@@ -833,10 +851,10 @@
|
|
|
833
851
|
return;
|
|
834
852
|
}
|
|
835
853
|
if (!type) {
|
|
836
|
-
type = '
|
|
854
|
+
type = 'tr';
|
|
837
855
|
}
|
|
838
856
|
//Translate
|
|
839
|
-
if (type === '
|
|
857
|
+
if (type === 'tr') {
|
|
840
858
|
return this.localizeService.getLocalizedValue(inputData);
|
|
841
859
|
}
|
|
842
860
|
//Date
|
|
@@ -847,19 +865,26 @@
|
|
|
847
865
|
if (type === 'dt') {
|
|
848
866
|
return this.localizeService.getLocalizedDateTime(inputData);
|
|
849
867
|
}
|
|
850
|
-
|
|
851
|
-
|
|
868
|
+
//DistanceInWords
|
|
869
|
+
if (type === 'dis') {
|
|
870
|
+
return this.localizeService.getLocalizedDistanceInWords(inputData, param2);
|
|
852
871
|
}
|
|
853
872
|
//DistanceToNowInWords
|
|
854
|
-
if (type === 'uldis2now') {
|
|
855
|
-
return this.localizeService.getUTCToLocalizedDistanceToNowInWords(inputData);
|
|
856
|
-
}
|
|
857
873
|
if (type === 'dis2now') {
|
|
858
874
|
return this.localizeService.getLocalizedDistanceToNowInWords(inputData);
|
|
859
875
|
}
|
|
860
|
-
//
|
|
861
|
-
|
|
862
|
-
|
|
876
|
+
//UTC Operations --------------------------------------------------------------
|
|
877
|
+
//UTC Date
|
|
878
|
+
if (type === 'u2d') {
|
|
879
|
+
return this.localizeService.getUTCToLocalizedDate(inputData);
|
|
880
|
+
}
|
|
881
|
+
//UTC DateTime
|
|
882
|
+
if (type === 'u2dt') {
|
|
883
|
+
return this.localizeService.getUTCToLocalizedDateTime(inputData);
|
|
884
|
+
}
|
|
885
|
+
//UTC DistanceToNowInWords
|
|
886
|
+
if (type === 'u2dis2now') {
|
|
887
|
+
return this.localizeService.getUTCToLocalizedDistanceToNowInWords(inputData);
|
|
863
888
|
}
|
|
864
889
|
return inputData;
|
|
865
890
|
};
|