Display Month in Spanish using strftime? - c

I am trying to get the format a date from 2018-09-01 to September 1, 2018.
I have been using:
strftime(displayDate, sizeof(displayDate), "%B %d %Y", &date_obj);
It works perfectly, but, is there a way to format the Month to be in Spanish?

The strftime function formats dates based on the current locale. So you'll need to set the locale for LC_TIME first:
setlocale(LC_TIME, "es_ES-UTF_8");
See setlocale for more information.

Related

Is it possible to get a long date in the current locale?

I can pass the result of nl_langinfo(D_FMT) to strftime to get a date string formatted according to the rules of the currently active locale. This works fine but it only allows me to get a short date, e.g. 21.01.2023 for January 21st, 2023 on a German system. On Windows I can also query LOCALE_SLONGDATE to get a long date, which would be something like Samstag, 21. Januar 2023 for January 21st, 2023 on a German system.
Is there any way to get such long date strings formatted according to the rules of the current locale on Linux?

angularjs Date Daylightsaving issue

I am using date to display my date on html like:
{{updateDate| date: 'dd/MM/yyyy HH:mm:ss'}}
Dates are all saved in UTC. The problem is it displays the date in locale timezone but not considering Daylight saving on/off. As in for BST it always shows +1 hr from UTC.
I want it to also consider DST(daylight saving time).
Any help, please.
{{ date_expression | date : format : timezone}}
As per angular date filter documentation:
date: Here date can be Date Object, milliseconds or ISO 8601 datetime string formats (like: e.g. yyyy-MM-ddTHH:mm:ss.sssZ). Here Z is 4 digit (+sign) representation of the timezone offset (-1200-+1200). If no timezone is specified in the string input, the time is considered to be in the local timezone.
format: this is optional, If not specified, mediumDate(equivalent to 'MMM d, y' for en_US locale (e.g. Sep 3, 2010)) is used.
timezone: Timezone to be used for formatting. It understands UTC/GMT and the continental US time zone abbreviations, but for general use, use a time zone offset, for example, '+0430' (4 hours, 30 minutes east of the Greenwich meridian) If not specified, the timezone of the browser will be used.
This may help you.

Date time not formating in AngularJs 1.6

I've got this format of date coming from an api:
"dateTime": "2018-02-19 00:00:00.000-08:00"
I just want the days, month and year in the format: dd/MM/yyyy
I'm using this in the view:
<td>{{dado.dateTime | date:'dd/MM/yyyy'}}</td>
But it's shows the date extacly as it comes from the API. Without any formatting
OBS: Angular 1.6
You are missing the T in your original DateTime. For ISO8601 DateTime it should be "2018-02-19T00:00:00.000-08:00" as the value. That is what can be translated by the angular date filter as a DateTime, currently it can only be interpreted as a string.
From the documentation on the input:
Date to format either as Date object, milliseconds (string or number) or various ISO 8601 datetime string formats (e.g. yyyy-MM-ddTHH:mm:ss.sssZ and its shorter versions like yyyy-MM-ddTHH:mmZ, yyyy-MM-dd or yyyyMMddTHHmmssZ). If no timezone is specified in the string input, the time is considered to be in the local timezone.
If you do not have any control over the server/source then you have a couple of options:
Change the value of the date time string in the factory/service when you receive the data so it is ISO8601 compliant. This can be as simple as using a regex or string concatenation as long as the T character is added between the date and time. In this specific case you could take the first 10 characters as you probably want to completely ignore the time portion but that would not work where you do want to show or keep time as a part of the datetime.
Create your own filter that then calls through to the built in date filter once you format the input correctly.

Support dates with optional month and day in angular date input or uib-dateparser

I want to support the dates in the following formats in my angular bootstrap input: YYYY, MM.YYYY and DD.MM.YYYY. At the same time I want to send to the server the dates in the following formats: YYYY, YYYY-MM, YYYY-MM-DD. The user enters the date from the keyboard, no datepicker is needed. Is there an easy way to do that? I saw uib-dateparser, but it seems that it doesn't support optional MM and DD.

Angular localization problems with number and date format

I am trying to format a date based on localisation and have the locale files setup correct so when using date format of shortDate I get the difference between UK and US format.
However we need the date to show the full year 2016 and not 16.
If I code it as dd MM yyyy then that gives me the correct UK format but when toggling to US mode the filter keeps it in that dd MM yyyy format.
How can I enable the date to be of type day month year for UK and month day year for US etc ?
Try https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString
// US English uses month-day-year order
console.log(date.toLocaleDateString('en-US'));
// → "12/19/2012"
// British English uses day-month-year order
console.log(date.toLocaleDateString('en-GB'));
// → "20/12/2012"
Note this is not IE friendly like most of html5 and ES6 :v.
other way is to use http://momentjs.com/

Resources