确定区域工作日和一周中的周末

发布于 2024-09-07 02:23:03 字数 57 浏览 5 评论 0原文

在某些国家/地区,周末是周五/周六。

Windows 应用程序如何找出用户的周末?

In some countries weekend days are Friday/Saturday.

How can a Windows application find out weekend days of the user?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

枕梦 2024-09-14 02:23:03

嗯……我不知道这个问题有“一个函数”的答案。你需要以某种方式知道他们在哪里。如果是网络应用程序,您可以追踪他们的 IP 并找出他们来自哪个国家/地区。如果它是 Windows 应用程序,您可能需要询问他们(时钟仅提供时区信息,我不知道还能从哪里获取更细粒度的位置)。

您可以使用 GetDayofWeek http:

如果您跳转到 .Net /en-us/library/system.dayofweek.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.dayofweek.aspx

您需要包含国家/地区/他们认为周末的日子的查找表..您可能必须构建此表,但您可以从以下位置获取国家/地区列表: http://www.iso.org/iso/english_country_names_and_code_elements

该列表是 ISO 3166。

它已更新,应该是您列表的“一站式商店”。从那里,您将“周末”与国家/地区相匹配。 http://en.wikipedia.org/wiki/Workweek 可能有助于确定周末/各国的工作周。

Wellll...I don't know of a "One function" answer to this. You're gonna need to know where they are somehow. If it's a webapp, you can trace their IP and figure out what country they are from. If it's a windows app, you're probably going to need to ask them (The clock only provides timezone information, and i can't figure out where else to grab a more fine-grained location from windows).

You can figure out what day it is with GetDayofWeek http://msdn.microsoft.com/en-us/library/1wzak8d0%28VS.80%29.aspx in MFC

DayofWeek if you hop to .Net http://msdn.microsoft.com/en-us/library/system.dayofweek.aspx

You'll need a lookup table with countries/what days they consider weekends..you'll probably have to construct this, but you can get a list of countries from: http://www.iso.org/iso/english_country_names_and_code_elements

That list is ISO 3166.

It's updated and should be your "one-stop-shop" for the listing. From there, you'll match "weekends" to the countries. http://en.wikipedia.org/wiki/Workweek might help in figuring out weekends/workweeks for countries.

十级心震 2024-09-14 02:23:03

以下代码将提供是否将其视为周末,并提供针对不同文化的选项(周末在不同的一天开始/结束):

    /// <summary>
    /// Returns true if the specified date is weekend in given culture
    /// is in. 
    /// </summary>
    public static bool IsItWeekend(DateTime currentDay, CultureInfo cultureInfo)
    {
        bool isItWeekend = false;

        DayOfWeek firstDay = cultureInfo.DateTimeFormat.FirstDayOfWeek;

        DayOfWeek currentDayInProvidedDatetime = currentDay.DayOfWeek;

        DayOfWeek lastDayOfWeek = firstDay + 4;

        if (currentDayInProvidedDatetime == lastDayOfWeek + 1 || currentDayInProvidedDatetime == lastDayOfWeek + 2)
            isItWeekend = true;

        return isItWeekend;         
    }

The following code will provide whether or not it is considered the weekend, with an option for different cultures (where the weekend starts/ends on a different day):

    /// <summary>
    /// Returns true if the specified date is weekend in given culture
    /// is in. 
    /// </summary>
    public static bool IsItWeekend(DateTime currentDay, CultureInfo cultureInfo)
    {
        bool isItWeekend = false;

        DayOfWeek firstDay = cultureInfo.DateTimeFormat.FirstDayOfWeek;

        DayOfWeek currentDayInProvidedDatetime = currentDay.DayOfWeek;

        DayOfWeek lastDayOfWeek = firstDay + 4;

        if (currentDayInProvidedDatetime == lastDayOfWeek + 1 || currentDayInProvidedDatetime == lastDayOfWeek + 2)
            isItWeekend = true;

        return isItWeekend;         
    }
梦过后 2024-09-14 02:23:03

ICU 项目可能会有所帮助。它是为软件国际化和全球化而设计的。提供 C/C++ 和 Java 版本。

icu-project.org

ICU project might help. It is designed for software internalization and globalization. C/C++ and Java version are available.

icu-project.org

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文