Socket
Socket
Sign inDemoInstall

nativescript-sdk-utility

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nativescript-sdk-utility - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

platforms/android/nativescript_sdk_utility.aar

5

index.d.ts

@@ -1,5 +0,8 @@

export declare class SDKUtility {
import { Common } from './sdk-utility.common';
export declare class SDKUtility extends Common {
getVersion(): string;
getBuild(): string;
is24HFormat(): boolean;
formatDateTime(date?: Date, pattern?: string, locale?: string): string;
}

2

package.json
{
"name": "nativescript-sdk-utility",
"version": "1.0.3",
"version": "1.0.4",
"description": "This plugin is a collection of utilities for iOS and Android to simplify your NativeScript apps.",

@@ -5,0 +5,0 @@ "main": "sdk-utility",

@@ -8,2 +8,3 @@ # NativeScript SDK Utility

- is24HFormat(): Returns a boolean value that indicates if the device is using a 24H time format.
- formatDateTime(date?: Date, pattern?: string, locale?: string): Returns a date based on given pattern.

@@ -26,2 +27,3 @@ ## Installation

var is24H = sdk.is24HFormat();
var datetime = this.sdk.formatDateTime(new Date(), "MM/dd/yyyy h:mm");
```)

@@ -46,2 +48,3 @@

this.is24H = this.sdk.is24HFormat();
this.datetime = this.sdk.formatDateTime(new Date(), "MM/dd/yyyy h:mm");
}

@@ -48,0 +51,0 @@ }

@@ -1,5 +0,7 @@

export declare class SDKUtility {
import { Common } from './sdk-utility.common';
export declare class SDKUtility extends Common {
getVersion(): any;
getBuild(): any;
is24HFormat(): boolean;
formatDateTime(date?: Date, pattern?: string, locale?: string): string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var sdk_utility_common_1 = require("./sdk-utility.common");
var application = require("tns-core-modules/application");
var utils_1 = require("tns-core-modules/utils/utils");
var SDKUtility = (function () {
var localesCache = new Map();
function getNativeLocale(locale) {
if (localesCache.has(locale)) {
return localesCache.get(locale);
}
var result;
if (locale) {
locale = locale.replace(/_/g, "-");
var firstHypenIndex = locale.indexOf("-");
var lang = "";
var country = "";
if (firstHypenIndex > -1) {
lang = locale.substr(0, firstHypenIndex);
var nextHypenIndex = locale.substr(firstHypenIndex + 1).indexOf("-");
country = locale.substr(firstHypenIndex + 1, (nextHypenIndex > -1) ? nextHypenIndex : undefined);
}
else {
lang = locale;
}
if (country !== "") {
result = new java.util.Locale(lang, country);
}
else {
result = new java.util.Locale(lang);
}
}
else {
result = new java.util.Locale("en", "US");
}
localesCache.set(locale, result);
return result;
}
var SDKUtility = (function (_super) {
__extends(SDKUtility, _super);
function SDKUtility() {
return _super !== null && _super.apply(this, arguments) || this;
}

@@ -21,5 +56,16 @@ SDKUtility.prototype.getVersion = function () {

};
SDKUtility.prototype.formatDateTime = function (date, pattern, locale) {
var dateFormat;
var nativeLocale = getNativeLocale(locale);
if (!pattern) {
dateFormat = java.text.DateFormat.getDateTimeInstance(0, 0, nativeLocale);
pattern = dateFormat.toPattern();
}
pattern = this.is24HFormat() ? pattern.replace(/h/g, "H") : pattern.replace(/H/g, "h");
var sdf = new java.text.SimpleDateFormat(pattern);
return sdf.format(date ? new java.util.Date(date.valueOf()) : new java.util.Date()).toString();
};
return SDKUtility;
}());
}(sdk_utility_common_1.Common));
exports.SDKUtility = SDKUtility;
//# sourceMappingURL=sdk-utility.android.js.map

@@ -0,1 +1,9 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Common = (function () {
function Common() {
}
return Common;
}());
exports.Common = Common;
//# sourceMappingURL=sdk-utility.common.js.map

@@ -1,5 +0,7 @@

export declare class SDKUtility {
import { Common } from './sdk-utility.common';
export declare class SDKUtility extends Common {
getVersion(): any;
getBuild(): any;
is24HFormat(): boolean;
formatDateTime(date?: Date, pattern?: string, locale?: string): string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var SDKUtility = (function () {
var sdk_utility_common_1 = require("./sdk-utility.common");
var SDKUtility = (function (_super) {
__extends(SDKUtility, _super);
function SDKUtility() {
return _super !== null && _super.apply(this, arguments) || this;
}

@@ -16,5 +19,19 @@ SDKUtility.prototype.getVersion = function () {

};
SDKUtility.prototype.formatDateTime = function (date, pattern, locale) {
var dateFormatter = NSDateFormatter.new();
if (locale) {
dateFormatter.locale = NSLocale.alloc().initWithLocaleIdentifier(locale);
}
if (!pattern) {
dateFormatter.dateStyle = 4;
dateFormatter.timeStyle = 3;
pattern = dateFormatter.dateFormat;
}
pattern = this.is24HFormat() ? pattern.replace(/h/g, "H") : pattern.replace(/H/g, "h");
dateFormatter.dateFormat = pattern;
return dateFormatter.stringFromDate(date ? date : new Date());
};
return SDKUtility;
}());
}(sdk_utility_common_1.Common));
exports.SDKUtility = SDKUtility;
//# sourceMappingURL=sdk-utility.ios.js.map
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc