# @bombaysoftwares/tskit

> The @bombaysoftwares/tskit package provides a set of utility functions for working with dates and timestamps in JavaScript. These functions simplify common tasks such as date formatting, timestamp conversion, and JSON validation.

Latest version **1.0.15** (published 2025-07-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @bombaysoftwares/tskit
pnpm add @bombaysoftwares/tskit
yarn add @bombaysoftwares/tskit
bun add @bombaysoftwares/tskit
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.15 |
| Published | 2025-07-23 |
| First published | 2023-06-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 106.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Bombay Softwares |
| Maintainers | jainarpit014, divyjain |
| Keywords | utility, functions, date-time, datetime, date, time, parse, format, validate, util, helper, date-time-format |

## Links

- npm: https://www.npmjs.com/package/@bombaysoftwares/tskit
- Repository: https://github.com/Edugem-Technologies/bombaysoftwares-tskit
- Homepage: https://github.com/Edugem-Technologies/bombaysoftwares-tskit#readme
- Issues: https://github.com/Edugem-Technologies/bombaysoftwares-tskit/issues
- npm.io page: https://npm.io/package/@bombaysoftwares/tskit

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 1.0.15 (latest) — 2025-07-23
- 1.0.14 — 2024-07-30
- 1.0.13 — 2024-07-17
- 1.0.12 — 2024-05-28
- 1.0.10 — 2023-08-22
- 1.0.9 — 2023-08-22
- 1.0.8 — 2023-07-12
- 1.0.7 — 2023-07-10
- 1.0.6 — 2023-07-03
- 1.0.5 — 2023-06-28
- 1.0.4 — 2023-06-27
- 1.0.3 — 2023-06-27
- 1.0.2 — 2023-06-26
- 1.0.1 — 2023-06-26
- 1.0.0 — 2023-06-22

## README

# tskit

The @bombaysoftwares/tskit package provides a comprehensive set of utility functions for various operations in JavaScript. These functions simplify common tasks such as date formatting, timestamp conversion, JSON validation, manipulating strings, and working with HTML content. This package is designed to enhance the functionality of various operations in your JavaScript projects.

## Installation

To use the Date Utils package, you can install it via npm:

```bash
npm i @bombaysoftwares/tskit
```

## Usage

Import the desired functions from the package:

```bash
import { getCurrentDateTime, getCurrentTimestamp, getDateTimeFromTimestamp } from '@bombaysoftwares/tskit';
```

## getCurrentDateTime

This function returns the current date and time in the format "YYYY-MM-DD HH:MM:SS".

```bash
const currentDateTime = getCurrentDateTime();
console.log(currentDateTime);
// Output: 2023-06-20 12:22:20
```

## isSet
This function checks if the value provided is none of this - null, undefined, empty string, "undefined", empty array as string.
```bash
console.log(isSet("null"));
// Output: false
```

## isSetNumber
This function checks if the value provided is not null or undefined.
```bash
console.log(isSetNumber(1));
// Output: true
console.log(isSetNumber(null));
// Output: false
```

## getArray
This function generates an array of numbers from 1 to the specified length.
```bash
console.log(getArray(5));
// Output: [1, 2, 3, 4, 5]
console.log(getArray(10));
// Output: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
```

## getUniqueValueFromArray
This function returns a new array containing only unique values from the input array, preserving the order of first occurrences. Only supports arrays containing a single data type.
```bash
const values = ["a", "b", "a", "c", "b"];
console.log(getUniqueValueFromArray(values));
// Output: ["a", "b", "c"]

const nums = [1, 2, 2, 3];
console.log(getUniqueValueFromArray(nums));
// Output: [1, 2, 3]
```

## formatTextToCapitalized
This function capitalizes the first letter of a given text and converts the rest to lowercase. Returns an empty string if input is undefined, null, or not a string.
```bash
console.log(formatTextToCapitalized("hello world"));
// Output: "Hello world"
console.log(formatTextToCapitalized("JAVASCRIPT"));
// Output: "Javascript"
```

## underscoreToCapitalizedText
This function converts an underscore-separated string to a space-separated, capitalized text. Handles non-string, empty, or falsy inputs gracefully.
```bash
console.log(underscoreToCapitalizedText("hello_world_example"));
// Output: "Hello World Example"
console.log(underscoreToCapitalizedText("user_name_email"));
// Output: "User Name Email"
```

## getRandomColor

This function generates a random color in hexadecimal format.

```bash
console.log(getRandomColor());
// Output: #62C5B9
```

## getTextFromHtml

Extracts text from an HTML string by removing HTML tags.

```bash
console.log(getTextFromHtml("<h1>Title</h1><p>This is a paragraph.</p>"); returns TitleThis is a paragraph.);
// Output: The extracted text without HTML tags.
```

## getDateTimeFromTimestamp

This function formats a timestamp into a string representation of date and time. You can choose whether to include seconds in the formatted string.

```bash
const timestamp = 1695193213;
const formattedDateTime = getDateTimeFromTimestamp(timestamp);
console.log(formattedDateTime);
// Output: 20-Sep-2023 12:30:13
```
## Other Functions

The package also includes other useful functions:
- `evalBooleanValue(value: string | boolean | undefined): boolean` : This function checks if the value provided is "true" or true.
- `dateAndTimeFormat(dateObject: Date, showSeconds = true): string | null` : Formats a Date object into a string representation of date and time.
- `dateFormat(dateObject: Date): string | null` : Formats a Date object into a string representation of date in DD-Mmm-YYYY format.
- `dateFormatHHMM(dateObject: Date): string | null` : Formats a Date object into a string representation of date and time in DD-Mmm-YYYY, HH:mm format.
- `getTwodigitFormat(data: number): string | number | null` : Converts a number to a two-digit format by adding a leading zero if necessary.
- `isValidJsonData(data: string): object | boolean` : Checks if a string is valid JSON data by attempting to parse it.
- `getLocalDate(dateAndTime: string): string | null` : Retrieves the local date in a specific format from the provided date and time string.
- `strToDate = (dateString: string, format: string): Date | null` : Parses the input date string based on the specified format and returns a Date object.
- `camelCaseKeys= (obj: {[x: string]: string | number}):{[x: string]: string | number}` : Converts the keys of an object from snake_case to camelCase.


For detailed usage and examples, refer to the inline documentation and code samples within each function.

## Author

[Bombay Softwares](https://www.bombaysoftwares.com/)

## License

This project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info.

---
_Source: https://npm.io/package/@bombaysoftwares/tskit · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
