Is there a human language that has months ordered alphabetically? [closed] - sorting

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 1 year ago.
Improve this question
So I like datestrings in ISO format ie 2021-12-25 - it means you can just apply a simple sort and dates are in the right order.
But sometimes it is nice to see months as English rather trying to remember if October is 8th or ninth or tenth month. (maybe its just me).
So 2021-Dec-25 is nice to read but I lose that sort quality - this date would now appear before Thanksgiving on 2021-Nov-25.
So I was wondering if there was a human language that can do both - is there a language where January comes before February in that language's alphabet. For example French fails here (Janvier > Fevrier).

Well, let's query the cultures: for each culture we get months' names and check if they are sorted (we compare original names with the sorted names).
C# code:
var result = CultureInfo
.GetCultures(CultureTypes.AllCultures)
.Where(ci => ci.DateTimeFormat
.MonthNames
.Where(month => !string.IsNullOrEmpty(month))
.Where(month => !Regex.IsMatch(month, "^M[0-9]+$"))
.Any())
.Where(ci => ci.DateTimeFormat
.MonthNames
.Where(month => !string.IsNullOrEmpty(month))
.SequenceEqual(ci
.DateTimeFormat
.MonthNames
.Where(month => !string.IsNullOrEmpty(month))
.OrderBy(month => month)))
.OrderBy(ci => ci.Name)
.Select(ci => $"{ci.Name} ({ci.EnglishName})");
Console.Write(string.Join(Environment.NewLine, result));
Outcome:
Empty
So, there are no such (lucky?) cultures on the Earth (at least known to .Net 5)
You can try AbbreviatedMonthNames, MonthGenitiveNames, but alas: the output will be empty as well.

Related

Laravel How to filter inputs before going to the DataBase? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 months ago.
Improve this question
Laravel How to filter inputs before going to the DataBase
what shoud i do to filter my inputs before saving to the database? i want it to be uniformed in like this format "Name" a uper case followed by lowercase.
in some cases like when the user register a full caps name i want it to be re format as the example "Name"
there's an especific PHP function to do what you need: ucfirst(). This function turns to Uppercase the first char from a string.
For example:
//If $request->name is 'JoHn' or whatever
$filtered_name = ucfirst($request->name);
//Returns 'John'
If is a case with two names, you can use the ucwords() PHP function (Turn first letter uppercase of every word from a string)
//If $request->name is 'OlivER JAMES'
$filtered_name = ucwords($request->name);
//Returns 'Oliver James'
Hope this help you.

Is it possible to create a REDCap question that autofills based on previous answers?

I am working on a research project and I have an eligibility screener. I'd like to have a question at the end that is hidden from participants that shows "eligible - yes or no?" and autofills based on their questions to previous answers. Is this possible; if so, how could I set this up?
You would set this field up as a calculated field, hiding it as necessary, and build the arithmetic from your inclusion/exclusion criteria such that it returns 1 for eligible and 0 for ineligible. You can then use this 'eligible' value for later conditional logic, branching logic, automated survey invitations, and so on.
For example, say your eligibility requirements were that the participant is 18 years or older, does not have type-1 diabetes, and has a BMI greater than 30. Your calculated field would be something like:
if([age] >= 18 and [t1_diabetes] = '0' and [bmi] > 30, 1, 0)

In FreeMarker adding one hour to current timestamp [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
In FreeMarker, I am trying to add one hour to a timestamp which is in the format "2016-08-11T20:06+06:00".
I have tried and searched on Google, but didn't find way to add hours to the current timestamp. The new timestamp should be current system timestamp plus one hour.
I am getting the following error.
For "." left-hand operand: Expected a hash, but this has evaluated to a date_or_time_or_datetime (wrapper: f.t.SimpleDate):
==> current [in nameless template at line 2, column 19]
FTL stack trace ("~" means nesting-related):
- Failed at: #assign newDate = current.add(10, 1) [in nameless template at line 2, column 1]
<#assign current= .now> <#assign newDate= current.add(10,1) > ${newDate}
I have tried this but getting above error. Please help me out.

Sorting algorithms in Ruby sorting only by first digit [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
So I've been implementing a few different sorting methods (quick, merge, and insertion) and came across seemed a tad bit impractical and was wondering if someone could explain the thought process behind the behavior.
The list im trying to sort is the following:
[20401, 11087, 2, 62176, 70095, 20947, 20098, 90914, 53475, 51251, 20065]
The feedback is:
["11087", "2", "20065", "20098", "20401", "20947", "51251", "53475", "62176", "70095", "90914"]
If I change the 2 over to 00002 then I get a properly sorted list
["00002", "11087", "20065", "20098", "20401", "20947", "51251", "53475", "62176", "70095", "90914"]
Thanks ahead of time!
The respective two outputs that you are demostrating in the OP can be obtained as follows:
a = [20401, 11087, 2, 62176, 70095, 20947, 20098, 90914, 53475, 51251, 20065]
a.sort.map &"%05d".method( :% )
#=> ["00002", "11087", "20065", "20098", "20401", "20947", "51251", "53475", "62176", "70095", "90914"]
a.map( &:to_s ).sort
#=> ["11087", "2", "20065", "20098", "20401", "20947", "51251", "53475", "62176", "70095", "90914"]
Now what was the question, again?

How do I loop through items in XML in Nokogiri in Ruby? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
Given I have XML from this address, how would I loop through the search/events/event events? What I mean is loop through the event items and print their details to the screen? So far I have the following code:
get_xml('/events/search', :location => 'London, United Kingdom', :date => 'Today').at('events')
get_xml being the method which takes the XML from the link above and selects the events node. How would I loop though the items in that events node?
Can you try this
require 'rubygems'
require 'net/http'
require 'rexml/document'
# Web search for
url = 'http://api.eventful.com/rest/events/search?app_key=PbFVZfjTXJQWrnJp&location=London&date=Today'
# get the XML data as a string
xml_data = Net::HTTP.get_response(URI.parse(url)).body
# extract event information
doc = REXML::Document.new(xml_data)
doc.elements.each('search/events/event/title') do |ele|
titles = ele.text
p titles
end
Output:
C:\Users\vinothini\Desktop>ruby sample_nokogiri.rb
"The Ladykillers"
"The 39 Steps"
"Wotever Sex 6 August"
"Phoenix Fringe"
"The Lion King"
"One Man, Two Guvnors"
"Tutorfair event 6th Aug"
"Thriller - Live"
"The Color Purple"
"Summer School Mid-Term Party"
Am i understood your requirement correctly?

Resources