![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
pk-date-helpers
Advanced tools
Supports conversions from all of PigKnows date formats from any format into any other format.
Usage:
import { convertDateToFormatType } from 'pk-date-helpers';
...
const newDate = convertDateToFormatType(inputFormat, destinationFormat, stringToConvert); // outputs in specified destination format
Usage:
import { convertDateToRegularString } from 'pk-date-helpers';
...
const newRegularString = convertDateToRegularString(inputFormat, stringToConvert); // outputs in yyyy-MM-dd format
NOTE: inputFormat
can be in either a standard format (i.e. 'REGULAR', 'NEWSHAM', etc) or Report / percent format.
Used for % style date formats instead of the string formats ("European", "THOUSAND", etc.). Used exclusively for reporting at this point in time. Requires that the input be in Regular format, or one of 7 supported shortcuts.
Usage:
import { convertPercentDateFormat } from 'pk-date-helpers';
...
const newRegularString = convertPercentDateFormat(destinationFormat, regularStringToConvert); // outputs in destination format
Shortcuts supported: 1,2,3,4,5,6 or 8.
"1 digit" Thousand day is translated into the Regular date value. (i.e. if I type in 1, then the system will translate that into 2018-04-14
"2 digits" Thousand day is again translated into the Regular date value (i.e.if I type in 10, it gets translated into 2018-04-23)
"3 digits" Thousand day is again translated into the Regular date value (i.e. if I type in 100, it gets translated into 2018-07-22)
"4 digits" Translates the MMDD into the current Regular date year format
"5 digits" Thousand day is translated into Regular date format (i.e. if I type in 17001, then the system translates that into 2018-04-14)
"6 digits" This is a Regular date format shortcut that allows you to enter a previous year (i.e. like YYMMDD, so 170101 would be translated into 2017-01-01)
"8 digits" this shortcut allows YYYYMMDD to be translated into Regular date format (i.e. if I enter 20170101, it will be translated into 2017-01-01).
Converts a shortcut of any format into its long form. For example, converting 0101
(a regular shortcut) into 2018-01-01
.
Usage:
import { convertShortcutDate } from 'pk-date-helpers';
...
const fullFormat = convertShortcutDate(inputAndOutputFormat, stringToConvert);
** Note: convertShortcutDate
should be wrapped in a try/catch in case an invalid number of characters is thrown in for a format, since it will throw errors. For example, inputting '123' as a shortcut for a 'REGULAR' date will throw 123 does match 'REGULAR' format or any of its shortcuts
.
Detects the format of a string, if it matches a known date format. Optional parameters guide the detection to ignore any conflicting formats.
Usage:
import { detectFormatType } from 'pk-date-helpers';
...
const generalDetection = detectFormatType(dateString, preferStandardFormats?, arrayOfFormatsToIgnore?);
// examples:
const detectAStandardFormat = detectFormatType('17001', true, ['THOUSAND']); // ignoring thousand, as this is probably newsham
const detectNonStandardFormat = detectFormatType('001', false, ['%n', '%t']); // ignoring %n and %t as this is probably %j
Note that shortcuts are not supported for detection. You must use the full version of any format for accurate detection.
This returns true / false for if the date is in the future.
This returns true / false for if the date is valid according to PigKnows rules. For example, any years prior to 1900, Feb 31, a month '14', etc.
Returns an array of formats that may appear the same from a regex / structure perspective. Useful for finding the third parameter in detectFormatType
above.
Usage:
import { getConflictingFormatsForType } from 'pk-date-helpers';
...
const ignoreStandardFormats = getConflictingFormatsForType('THOUSAND'); // returns ['NEWSHAM']
const ignoreReportFormats = getConflictingFormatsForType('%y-%m-%d'); // returns ['%d-%m-%y', '%m-%d-%y']
Supported Shortcuts (standard formats only):
6-digit date (either dd/mm/yy, mm/dd/yy, or yy/mm/dd):
- If 'ignoredFormats' includes *both* of the 2 possible conflicts (i.e. 'AMERICAN', 'EUROPEAN' for 'REGULAR'), then this will detect properly. If you do not pass in these possible conflicts, it will fail. Conflicts detected for Julian, for example, will return 'INVALID DATE' with this shortcut because it does not know which format is intended.
1, 2, 3, and 5-digit shortcuts
- Order of Preference: Thousand, Julian, Newsham
- By default, one of these shortcuts will return 'THOUSAND', unless 'THOUSAND' is added to 'ignoredFormat'. The same applies to Julian and Newsham, but 'ignoredFormats' must include 'THOUSAND' to reach 'JULIAN', and 'ignoredFormats' must include both 'THOUSAND' and 'JULIAN' to reach 'NEWSHAM'.
NOTE: Shortcut conflicts do not have perfect detection, as there are many conflicts.
FAQs
date conversions used throughout pigknows products
We found that pk-date-helpers demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.