npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mui-ethiopian-datepicker

v0.3.2

Published

An Ethiopian date picker component designed for React applications. Built on top of Material-UI.

Downloads

591

Readme

MUI Ethiopian DatePicker

Current Version: 0.3.2

mui-ethiopian-datepicker is a React component for selecting Ethiopian dates. It's built on top of Material-UI and provides a culturally tailored date picker experience integrated seamlessly with other MUI components.

Screenshot of DatePicker

Installation

You can install the package using npm:

npm install mui-ethiopian-datepicker

Peer Dependencies

"peerDependencies": {
  "@emotion/react": "^11.11.0",
  "@emotion/styled": "^11.11.0",
  "@mui/icons-material": "^5.14.6",
  "@mui/material": "^5.14.6",
  "@mui/x-date-pickers": "^6.11.2",
  "date-fns": "^2.30.0",
  "react": "^18.2.0",
  "react-dom": "^18.2.0"
}

You can install them using:

npm install @mui/icons-material @mui/material @mui/x-date-pickers date-fns react react-dom

Usage

Basic Usage with EtDatePicker

import React, { useState } from "react";
import EtDatePicker from "mui-ethiopian-datepicker";

function MyComponent() {
  const [date, setDate] = useState(null);

  return (
    <EtDatePicker
      label="Document Date"
      onChange={(selectedDate: Date) => {
        setDate(selectedDate);
      }}
      value={date}
      minDate={new Date("2023-08-20")}
      maxDate={new Date("2023-08-26")}
      
      // other TextField props here, except InputProps
    />
  );
}

Localization Support in Version 0.1.7

Starting from version 0.1.7, mui-ethiopian-datepicker introduces localization support for different Ethiopian localizations. This feature allows a more tailored experience for users.

1. First, you need to import the EtLocalizationProvider from the mui-ethiopian-datepicker package.


import { EtLocalizationProvider } from 'mui-ethiopian-datepicker';

2. Wrap Your Application or Component:

Use the EtLocalizationProvider to wrap your entire application or just the section where the date picker is used. This will ensure that all date pickers within this context are localized.


function MyApp({ children }) {
  return (
    <EtLocalizationProvider localType="AMH">
      {children}
    </EtLocalizationProvider>
  );
}

3. Configure the Localization Provider:

The EtLocalizationProvider accepts the following props to configure the localization:

localType: This can be set to "AMH" (Amharic), "AO" (Afan Oromo), or "CUSTOM". It defines the type of localization you want to apply. "AMH" and "AO" are predefined localizations, while "CUSTOM" allows for more personalized configurations.

getLocalMonthName: This optional function is used only when localType is set to "CUSTOM". It allows you to provide a custom function to return the name of the month based on the month number.

function MyApp() {
  const getCustomMonthName = (month: number) => {
    // Define custom month names
    const customMonthNames = ["Custom Month 1", "Custom Month 2", ...];
    return customMonthNames[month - 1];
  };

  return (
    <EtLocalizationProvider localType="CUSTOM" getLocalMonthName={getCustomMonthName}>
      {children}
    </EtLocalizationProvider>
  );
}

Using EtDateViewer

import { EtDateViewer } from "mui-ethiopian-datepicker";

<EtDateViewer date={new Date()}  sx={{ color: "red" }} variant="h6" />

EthiopianDateUtil

EthiopianDateUtil is a utility module that provides various functions for working with Ethiopian dates. Here are some of the key functionalities:

Creating an Ethiopian Date

import { EthiopianDate } from 'mui-ethiopian-datepicker';

const date = EthiopianDate.createEthiopianDateFromParts(23, 7, 2013);

Convert To and From Gregorian

import { EthiopianDate } from 'mui-ethiopian-datepicker';

const etDate = EthiopianDate.toEth(new Date());
const grDate = EthiopianDate.toGreg(etDate);

Getting Ethiopian Months

import { EthiopianDate } from 'mui-ethiopian-datepicker';

const months = EthiopianDate.ethMonths;

Examples

Convert a Gregorian Date to Ethiopian Date

const etDate = EthiopianDate.toEth(new Date());

Convert an Ethiopian Date to Gregorian Date

const grDate = EthiopianDate.toGreg({ Day: 23, Month: 7, Year: 2013 });

Get the Names of Ethiopian Months

const months = EthiopianDate.ethMonths;

For more functionalities, refer to the source code.

Support and Contributions

Feel free to open issues or PRs if you find any problems or have suggestions for improvements.