首页 \ 问答 \ 使用C#或MonoTouch格式显示每月的星期几(Format to show day of week in month using C# or MonoTouch)

使用C#或MonoTouch格式显示每月的星期几(Format to show day of week in month using C# or MonoTouch)

我正在尝试在MonoTouch项目中格式化日期以显示如下字符串:

 1st Saturday of the month, February 2, 2013

但我一直无法找到在C#中格式化它的方法。

我以前能够通过使用格式化程序在Objective C中执行此操作:

 [dateFormatter setDateFormat:@"F'st' EEEE 'of the month', MMMM d, yyyy"];

并将'2nd'替换为'2nd','3st'替换为'3rd'等,但我无法找到'F'字符的替代品。

有没有办法在C#中做到这一点?


I'm trying to format a date in a MonoTouch project to display a string like:

 1st Saturday of the month, February 2, 2013

but I have been unable to find a way to format it in C#.

I have previously been able to do this in Objective C by using a formatter like:

 [dateFormatter setDateFormat:@"F'st' EEEE 'of the month', MMMM d, yyyy"];

and replacing '2st' with '2nd', '3st' with '3rd', etc but I have been unable to find a replacement for the 'F' character.

Is there any way to do this in C#?


原文:https://stackoverflow.com/questions/14901866
更新时间:2023-09-01 09:09

最满意答案

最简单的方法是简单地创建一个属性编辑器,如umbraco中内置的标签,然后确保它不会在UI中显示任何内容。 然后,您可以使用此编辑器向成员添加自定义属性,您可以通过代码在其中保存值,而无需在后台UI中显示它。

这里有关于创建属性编辑器的说明。 您可以跳过大部分的部分,因为您不需要显示或能够通过后台编辑编辑器中的值 - 您只是将其用作一种数据容器,用于访问和修改您的隐藏值码。

https://our.umbraco.org/documentation/tutorials/Creating-a-Property-Editor/


The easiest way is to simply create a property editor like the label one built into umbraco and then make sure it just doesn't display anything in the UI. Then you can add a custom property to the member using this editor and you will be able to save a value in it by code without having it show up in the backoffice UI.

There's instructions on creating a property editor here. You can skip over most of he parts as you would not need to show or be able to edit the value in the editor via the backoffice - you're simply using it as a sort of data container for your hidden value accessed and modified only by code.

https://our.umbraco.org/documentation/tutorials/Creating-a-Property-Editor/

相关问答

更多
  • 您可以将该属性作为true / false数据类型添加到任何选项卡。 然而,重要的是要注意,umbracoNaviHide没有做任何特殊的事情,它只是一个魔术字符串,当它被实现为真/假数据类型时,它可以与 .Where("Visible"). 我个人不再使用它。 如果我需要让项目可见或不可见,那么我会更具体地命名该物业。 例如,在实现希望某些节点可见但不是其他节点的菜单时,它通常很有用。 我通常有一个Menu选项卡,其中一个属性是名为Show in menu的真/假类型,其别名为showInMenu 。 ...
  • 通过调用GetMedia()和变量中的@parentID属性,我可以使用以下方法: ...
  • 最简单的方法是简单地创建一个属性编辑器,如umbraco中内置的标签,然后确保它不会在UI中显示任何内容。 然后,您可以使用此编辑器向成员添加自定义属性,您可以通过代码在其中保存值,而无需在后台UI中显示它。 这里有关于创建属性编辑器的说明。 您可以跳过大部分的部分,因为您不需要显示或能够通过后台编辑编辑器中的值 - 您只是将其用作一种数据容器,用于访问和修改您的隐藏值码。 https://our.umbraco.org/documentation/tutorials/Creating-a-Property ...
  • 向成员类型添加属性可以(并且应该)在后台完成: 然后设置/保存值应该是这样的(使用MemberService),虽然我不确定它是否是最新的:-s: // Get the member var member = Member.GetCurrentMember(); // Check if there is a current member if (member != null) { // Update member properties member.getProperty("myPrope ...
  • 如果你想在不知道别名或id的情况下获取属性,那么你将需要遍历属性,并且你可能会得到不止一种类型的属性。 我不确定上下文是什么,但看起来Umbraco发布的缓存不包含属性编辑器类型。 这意味着你不能在视图中进行如下操作: foreach (var property in Model.Properties.Where(x => x.PropertyType.PropertyEditorAlias == "Umbraco.Textbox")) { var propValue = property.Valu ...
  • 发现有一个标签数据类型,好像我错过了,傻我。 Found out there is a label data type, seems like I missed it, silly me.
  • 请访问: http : //www.systenics.com/blog/create-a-responsive,-fluid-html5css3-based-website-on-umbraco-7-using-bootstrap-30-framework/?tag=Umbraco+7并在页面上查找umbracoNaviHide ,您将看到如何设置此属性。 链接中的相关文字: 切换到Generic属性选项卡,然后单击Click here添加新属性链接... 通过转到Settings->DocumentTy ...
  • 输入元素是void元素,因此该代码无效, ''+responseObj.all.r[i].rId+'' 所以尝试用这个替换这个代码, '' 注意 : id应该是unique 。 在你的上下文中,你必须在每个循环中使用相同的id,如id="refid" , id="accept" ...
  • 这是可能的,但不完全是直截了当的。 查看可用的Umbraco数据服务 - 您需要从DataTypeService检索DataTypeService并使用ContentType检索Model的IPublishedContent的ContentTypeService 。 获得这些后,您可以根据PropertyType的DataTypeDefinitionId将ContentType上的PropertyType与检索到的DataTypeDefionitions匹配。 PropertyTypes具有Alias属性, ...
  • Umbraco使用客户端依赖关系框架将所有必需的资产组合在一起。 然后将它们缓存并存储在\App_Data\TEMP\ClientDependency\ 。 您可以删除这些以刷新缓存。 您可以通过将应用程序置于调试模式来阻止Umbraco使用CDF。 在Web.config ,找到compilation项并将debug更改为true : 当 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)