
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
Tiny (1 KB when miniified and gzipped) & easy to use library for date formatting
Download the t4mat.min.js file from the dist directory.
npm install --save t4mat
Note: This library can be either used in node or in the browser. The following examples are using the node environment.
const t4mat = require("t4mat");
var myDate = "2016-01-01T16:40:01.083Z"; // ISO string
var formatted = t4mat({
t:myDate,
format:"{yyyy} - {m} - {d}"
});
// > "2016 - 1 - 1"
As the above example demonstrates, the library is a mere function that takes an object as an argument, this object would have the following properties:
time (aliases: t1,t): The date in question, which can be a milliseconds since the epoch time (e.g. 1451666401083), an ISO String like the example above, or a date object. In fact it can be any value that the new Date() constructor in javascript can take.{d} / {m} would return: 1 / 1, while this format: {yyyy} ({d}) would return: 2016 (1). The following shortcodes are available in the format:
{d} The day of the month (Example: 1).{dd} The day of the month with a 0 prefix when it's less than 10 (Example: 01).{D} The day of the week, short version (Example: Wed.).{DD} The day of the week, full version (Example: Wednesday).{m} The numerical representation of the month (Example: 1).{mm} The numerical representation of the month, with a 0 prefix when it's less than 10 (Example: 01).{M} The literal representation of the month, short version (Example: Jan.).{MM} The literal representation of the month, full version (Example: January).{Y} Two digits representation of the year (Example: 16).{y} same as above.{YY} same as above.{yy} same as above.{YYYY} Full year (Example 2016).{yyyy} same as above.{yyy} same as above.{YYY} same as above.{R} Relative representation of the date/time, short version (Example 4 yrs ago).{RR} Relative representation of the date/time, full version (Example 4 years ago).By default the time you pass in the object will be represented relatively to the current time. However, if you want it to be calculated relative to another time, pass the base time as base in the object.
Let's suppose that the current time in the browser is 2016-01-02T00:00:00.000Z
Running this code:
var formatted = t4mat({
time:"2016-01-01T00:00:00.000Z",
format:"{RR}"
});
console.log(formatted);
// > "1 day ago"
var formatted2 = t4mat({
time:"2016-01-03T00:00:00.000Z",
format:"{RR}"
});
console.log(formatted2);
// > "in 1 day"
So by default the relative time calculation takes the current browser/machine time as the base. However if you wanted to pass your own base time then pass it as t2:
var formatted = t4mat({
time:"2016-01-01T00:00:00.000Z",
base:"2016-01-02T00:00:00.000Z"
format:"{RR}"
});
console.log(formatted);
// > "1 day ago"
var formatted2 = t4mat({
time:"2016-01-01T00:00:00.000Z", // same as above
base:"2016-01-03T00:00:00.000Z" // different base time
format:"{RR}"
});
console.log(formatted2);
// > "2 day ago"
FAQs
Tiny & easy to use library for date formatting
The npm package t4mat receives a total of 13 weekly downloads. As such, t4mat popularity was classified as not popular.
We found that t4mat demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.