Code Monkey home page Code Monkey logo

Comments (7)

Anheledir avatar Anheledir commented on September 24, 2024
public enum DiscordCountry : int
{
    Unknown = 0,
    UnitedStates = 1,
    Canada = 2,
    UnitedKingdom = 3,
    Australia = 4,
    Germany = 5,
    France = 6,
    Brazil = 7,
    Mexico = 8,
    Netherlands = 9,
    Sweden = 10,
    Norway = 11,
    Denmark = 12,
    Finland = 13,
    Spain = 14,
    Italy = 15,
    Poland = 16,
    Russia = 17,
    Japan = 18,
    SouthKorea = 19,
    China = 20,
    India = 21,
    Turkey = 22,
    Indonesia = 23,
    Philippines = 24
}

from honeycomb.

Anheledir avatar Anheledir commented on September 24, 2024
public static class DiscordCountryExtensions
{
    public static string GetFlaggedCountryName(this DiscordCountry country)
    {
        string countryCode = country.ToString().ToLower();

        // Convert country code to flag emoji
        countryCode = countryCode.Replace("unitedstates", "us");
        countryCode = countryCode.Replace("unitedkingdom", "gb");
        countryCode = countryCode.Replace("southkorea", "kr");
        countryCode = countryCode.Replace("philippines", "flag-ph");
        countryCode = countryCode.Replace("netherlands", "flag-nl");
        countryCode = countryCode.Replace("denmark", "flag-dk");
        countryCode = countryCode.Replace("finland", "flag-fi");

        countryCode = countryCode.Replace(" ", "-");
        countryCode = countryCode.Replace("é", "e");

        countryCode = $":flag-{countryCode}:";
        string countryName = country.ToString();

        // Capitalize first letter of each word
        TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;
        countryName = textInfo.ToTitleCase(countryName.ToLower().Replace("_", " "));

        return $"{countryCode} {countryName}";
    }
}

from honeycomb.

Anheledir avatar Anheledir commented on September 24, 2024
public enum CountryLanguage : int
{
    Unknown = 0,
    English = 1,                // United States, Canada, United Kingdom, Australia
    German = 2,                 // Germany
    French = 3,                 // France
    Portuguese = 4,             // Brazil
    Spanish = 5,                // Mexico, Spain
    Dutch = 6,                  // Netherlands
    Swedish = 7,                // Sweden
    Norwegian = 8,              // Norway
    Danish = 9,                 // Denmark
    Finnish = 10,               // Finland
    Polish = 11,                // Poland
    Russian = 12,               // Russia
    Japanese = 13,              // Japan
    Korean = 14,                // South Korea
    Chinese = 15,               // China
    Hindi = 16,                 // India
    Turkish = 17,               // Turkey
    Indonesian = 18,            // Indonesia
    Filipino_Tagalog = 19       // Philippines
}

from honeycomb.

Anheledir avatar Anheledir commented on September 24, 2024
public static class CountryLanguageExtensions
{
    public static string GetFlaggedLanguageName(this CountryLanguage language)
    {
        string languageCode = language.ToString().ToLower();

        // Convert language code to flag emoji
        switch (language)
        {
            case CountryLanguage.English:
                languageCode = "gb";
                break;
            case CountryLanguage.German:
                languageCode = "de";
                break;
            case CountryLanguage.French:
                languageCode = "fr";
                break;
            case CountryLanguage.Portuguese:
                languageCode = "pt";
                break;
            case CountryLanguage.Spanish:
                languageCode = "es";
                break;
            case CountryLanguage.Dutch:
                languageCode = "nl";
                break;
            case CountryLanguage.Swedish:
                languageCode = "se";
                break;
            case CountryLanguage.Norwegian:
                languageCode = "no";
                break;
            case CountryLanguage.Danish:
                languageCode = "dk";
                break;
            case CountryLanguage.Finnish:
                languageCode = "fi";
                break;
            case CountryLanguage.Polish:
                languageCode = "pl";
                break;
            case CountryLanguage.Russian:
                languageCode = "ru";
                break;
            case CountryLanguage.Japanese:
                languageCode = "jp";
                break;
            case CountryLanguage.Korean:
                languageCode = "kr";
                break;
            case CountryLanguage.Chinese:
                languageCode = "cn";
                break;
            case CountryLanguage.Hindi:
                languageCode = "in";
                break;
            case CountryLanguage.Turkish:
                languageCode = "tr";
                break;
            case CountryLanguage.Indonesian:
                languageCode = "id";
                break;
            case CountryLanguage.Filipino_Tagalog:
                languageCode = "ph";
                break;
            default:
                return language.ToString();
        }

        languageCode = $":flag-{languageCode}:";
        string languageName = language.ToString();

        // Capitalize first letter of each word
        TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;
        languageName = textInfo.ToTitleCase(languageName.ToLower().Replace("_", " "));

        return $"{languageCode} {languageName}";
    }
}

from honeycomb.

Anheledir avatar Anheledir commented on September 24, 2024
public enum Timezone
{
    Unknown = 0,
    InternationalDateLineWest = -720,
    Samoa = -660,
    Hawaii = -600,
    Alaska = -540,
    Pacific = -480,
    Mountain = -420,
    Central = -360,
    Eastern = -300,
    Atlantic = -240,
    Newfoundland = -210,
    Brazilia = -180,
    MidAtlantic = -120,
    Azores = -60,
    GMT = 0,
    CentralEuropean = 60,
    EasternEuropean = 120,
    Moscow = 180,
    Gulf = 240,
    Pakistan = 300,
    India = 330,
    Nepal = 345,
    Bangladesh = 360,
    Myanmar = 390,
    Indochina = 420,
    China = 480,
    Korea = 540,
    Japan = 540,
    AustraliaEastern = 600,
    AustraliaCentral = 570,
    AustraliaWestern = 480,
    PacificIslands = 660,
    NewZealand = 720
}

from honeycomb.

Anheledir avatar Anheledir commented on September 24, 2024
public static class TimezoneExtensions
{
    public static string GetFlaggedTimezoneName(this Timezone timezone)
    {
        string timezoneCode = timezone.ToString().Replace("_", " ");

        if (timezone == Timezone.Unknown)
        {
            return "Unknown";
        }

        string timezoneEmoji = $":flag-{timezone.ToString().ToLower()}:";
        string timezoneName = timezoneCode;

        // Capitalize first letter of each word
        TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;
        timezoneName = textInfo.ToTitleCase(timezoneName.ToLower());

        return $"{timezoneEmoji} {timezoneName}";
    }
}

from honeycomb.

Anheledir avatar Anheledir commented on September 24, 2024
public static class DateTimeExtensions
{
    public static DateTime ToTimezone(this DateTime dateTime, Timezone timezone)
    {
        int minutesToAdjust = (int)timezone;
        TimeSpan timeSpan = new TimeSpan(0, minutesToAdjust, 0);
        return dateTime + timeSpan;
    }

    public static DateTime ToUtcFromTimezone(this DateTime dateTime, Timezone timezone)
    {
        int minutesToAdjust = (int)timezone;
        TimeSpan timeSpan = new TimeSpan(0, -minutesToAdjust, 0);
        return dateTime + timeSpan;
    }
}

from honeycomb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.